PHP: Undefined offset

后端 未结 4 673
感动是毒
感动是毒 2020-12-20 02:55

On some pages, i receive the error:

PHP Notice: Undefined offset: 1 in /var/www/example.com/includes/head.php on line 23

Here

4条回答
  •  情歌与酒
    2020-12-20 03:22

    list($r1, $r2) = explode(" ", $r[0],2);
    

    When supplied with two variables, list() will need an array with at least 2 items.
    However, as the error you mentioned indicates, your explode() call seems to return an array with only one item.

    You will have to check the contents of $r[0] to make sure it actually contains your splitting character or manually assign $r1 and $r2 with sanity checks.

提交回复
热议问题