2017-10-06 36 views
0

不支持运营商的字符串我有一些代码在WordPress
我有错误PHP致命错误:[]操作不[]在WordPress

$file1 = ''; 
while (false !== ($file1 = readdir($dir2))) { 
    if($file1 != "." && $file1 != "..") { 
    $files[$item][] = $file1; 
    } 
} 

支持字符串我使用的PHP 5.4的版本。有任何想法吗?

+0

'$ files [$ item]'是一个字符串,而不是一个数组。 https://3v4l.org/GXuXg – naththedeveloper

回答

0

readdir()接受文件句柄,而不是一个字符串:

manual报价:

dir_handle: The directory handle resource previously opened with opendir() . If the directory handle is not specified, the last link opened by opendir() is assumed.`

因此,也许使用opendir()第一?