Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
警告:升级PHP时从joomla中的空值创建默认对象_Php_Joomla - Fatal编程技术网

警告:升级PHP时从joomla中的空值创建默认对象

警告:升级PHP时从joomla中的空值创建默认对象,php,joomla,Php,Joomla,我为这个问题搜索了很多。但是找不到确切的答案。我得到了这个错误警告:从第85行mod_random_image/helper.php中的空值创建默认对象。我的代码如下: 58 function getImages(&$params, $folder) 59 { 60 $type = $params->get( 'type', 'jpg' ); 61 62

我为这个问题搜索了很多。但是找不到确切的答案。我得到了这个错误警告:从第85行mod_random_image/helper.php中的空值创建默认对象。我的代码如下:

 58         function getImages(&$params, $folder)
 59         {
 60                 $type           = $params->get( 'type', 'jpg' );
 61 
 62                 $files  = array();
 63                 $images = array();
 64 
 65                 $dir = JPATH_BASE.DS.$folder;
 66 
 67                 // check if directory exists
 68                 if (is_dir($dir))
 69                 {
 70                         if ($handle = opendir($dir)) {
 71                                 while (false !== ($file = readdir($handle))) {
 72                                         if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html' ) {
 73                                                 $files[] = $file;
 74                                         }
 75                                 }
 76                         }
 77                         closedir($handle);
 78 
 79                         $i = 0;
 80                         foreach ($files as $img)
 81                         {
 82                                 if (!is_dir($dir .DS. $img))
 83                                 {
 84                                         if (preg_match("#$type#i", $img)) {
 85                                                 $images[$i]->name       = $img;
 86                                                 $images[$i]->folder     = $folder;
 87                                                 ++$i;
 88                                         }
 89                                 }
 90                         }
 91                 }
 92 
 93                 return $images;
 94         }
这个错误是在我将PHP版本升级到5.4.8之后出现的。我还研究了joomla配置文件。我设置var$error_reporting='-1';在joomla配置中。但我还是犯了同样的错误。我以前没用过Joomla

任何帮助都将不胜感激。
谢谢

发生错误的原因是,
$images[$i]
尚未定义为对象,PHP隐式实例化了默认对象(类型为
stdClass
)。要解决此问题,只需在第85行之前添加此行:

$images[$i] = new stdClass();

奇怪的是,它被定义为数组。似乎不匹配。谢谢您的快速回复。致命错误:无法在helper.php中将stdClass类型的对象用作数组。这是我在插入$images=new stdClass()时遇到的错误+1 Jeffrey您是否要发送拉取请求以修复该问题?mod_random_图像(它是一个核心模块)