我收到此错误:function split() deprecated
list ($kk, $vv) = split( ' ', $buf, 2);
当我用 explode
或 preg_split
替换它时,我得到了这个错误 Undefined offset: 1 E_NOTICE Error in file
list ($kk, $vv) = explode( " ", $buf, 2);
这是完整的代码
function get_toprotatingbanners()
{
$s = array ();
$file = fopen ('inc/adsadmin/toprotatingbanners.php', 'r');
if ($file)
{
while ($buf = fgets ($file, 20000))
{
$buf = chop ($buf);
if (($buf != '<?/*' AND $buf != '*/?>'))
{
list ($kk, $vv) = explode(" ", $buf, 2);
$s[$kk] = $vv;
continue;
}
}
}
fclose ($file);
return $s;
}
请帮帮我。
最佳答案
函数拆分已弃用“此函数在 PHP 5.3.0 中已弃用,在 PHP 7.0.0 中已删除。”正如你在 php.net/manual/en/function.split.php 上看到的那样
Undefined offset: 1 是因为 $buf 未定义。
关于php - 函数 split() 已弃用并爆炸 .... undefined offset : 1 E_NOTICE Error in file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36370456/