php警告-为foreach()提供的参数无效

php警告-为foreach()提供的参数无效,php,mysql,arrays,yii,Php,Mysql,Arrays,Yii,我安装了一个在php mysql yii框架上工作的项目edusec学校管理系统。但是当我们复制它的根目录并在本地服务器上运行index.php时,它会给出以下错误?我做什么?请帮帮我 PHP warning Invalid argument supplied for foreach() C:\xampp\htdocs\yiitest\protected\yii\framework\collections\CMap.php(288) 276 * @param array $

我安装了一个在php mysql yii框架上工作的项目edusec学校管理系统。但是当我们复制它的根目录并在本地服务器上运行index.php时,它会给出以下错误?我做什么?请帮帮我

   PHP warning

Invalid argument supplied for foreach()

C:\xampp\htdocs\yiitest\protected\yii\framework\collections\CMap.php(288)

276      * @param array $b array to be merged from. You can specifiy additional
277      * arrays via third argument, fourth argument etc.
278      * @return array the merged array (the original arrays are not changed.)
279      * @see mergeWith
280      */
281     public static function mergeArray($a,$b)
282     {
283         $args=func_get_args();
284         $res=array_shift($args);
285         while(!empty($args))
286         {
287             $next=array_shift($args);
288             foreach($next as $k => $v)
289             {
290                 if(is_integer($k))
291                     isset($res[$k]) ? $res[]=$v : $res[$k]=$v;
292                 else if(is_array($v) && isset($res[$k]) && is_array($res[$k]))
293                     $res[$k]=self::mergeArray($res[$k],$v);
294                 else
295                     $res[$k]=$v;
296             }
297         }
298         return $res;
299     }
300 
Stack Trace
#0  
–  C:\xampp\htdocs\yiitest\protected\yii\framework\base\CModule.php(468): CMap::mergeArray(array("class" => "CDbConnection"), 1)
463         foreach($components as $id=>$component)
464         {
465             if($component instanceof IApplicationComponent)
466                 $this->setComponent($id,$component);
467             else if(isset($this->_componentConfig[$id]) && $merge)
468                 $this->_componentConfig[$id]=CMap::mergeArray($this->_componentConfig[$id],$component);
469             else
470                 $this->_componentConfig[$id]=$component;
471         }
472     }
473 
#1  
+  C:\xampp\htdocs\yiitest\protected\yii\framework\base\CComponent.php(153): CModule->setComponents(array("user" => array("allowAutoLogin" => true, "class" => "RWebUser"), "phpThumb" => array("class" => "ext.EPhpThumb.EPhpThumb"), "authManager" => array("class" => "RDbAuthManager"), "urlManager" => array("urlFormat" => "path", "rules" => array("<controller:\w+>/<id:\d+>" => "<controller>/view", "<controller:\w+>/<action:\w+>/<id:\d+>" => "<controller>/<action>", "<controller:\w+>/<action:\w+>" => "<controller>/<action>")), ...))
#2  
+  C:\xampp\htdocs\yiitest\protected\yii\framework\base\CModule.php(483): CComponent->__set("components", array("user" => array("allowAutoLogin" => true, "class" => "RWebUser"), "phpThumb" => array("class" => "ext.EPhpThumb.EPhpThumb"), "authManager" => array("class" => "RDbAuthManager"), "urlManager" => array("urlFormat" => "path", "rules" => array("<controller:\w+>/<id:\d+>" => "<controller>/view", "<controller:\w+>/<action:\w+>/<id:\d+>" => "<controller>/<action>", "<controller:\w+>/<action:\w+>" => "<controller>/<action>")), ...))
#3  
+  C:\xampp\htdocs\yiitest\protected\yii\framework\base\CApplication.php(144): CModule->configure(array("name" => "College Management System", "preload" => array("log"), "import" => array("application.models.*", "application.extensions.jtogglecolumn.*", "application.extensions.AjaxList.AjaxList", "application.components.*", ...), "modules" => array("gii" => array("class" => "system.gii.GiiModule", "password" => "secure", "generatorPaths" => array("ext.gii-extended"), "ipFilters" => array("127.0.0.1", "::1", "192.168.0.163")), 0 => "notification", 1 => "webservice", "rights" => array("install" => false, "superuserName" => "SuperAdmin", "authenticatedName" => "Authenticated", "userIdColumn" => "user_id", ...), ...), ...))
#4  
+  C:\xampp\htdocs\yiitest\protected\yii\framework\YiiBase.php(127): CApplication->__construct("C:\xampp\htdocs\yiitest/protected/config/main.php")
#5  
+  C:\xampp\htdocs\yiitest\protected\yii\framework\YiiBase.php(100): YiiBase::createApplication("CWebApplication", "C:\xampp\htdocs\yiitest/protected/config/main.php")
#6  
–  C:\xampp\htdocs\yiitest\index.php(18): YiiBase::createWebApplication("C:\xampp\htdocs\yiitest/protected/config/main.php")
13 
14 // specify how many levels of call stack should be shown in each log message
15 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
16 
17 require_once($yii);
18 Yii::createWebApplication($config)->run();
19 ?>
20 
PHP警告
为foreach()提供的参数无效
C:\xampp\htdocs\yiitest\protected\yii\framework\collections\CMap.php(288)
276*@param数组$b要从中合并的数组。你可以指定额外的
277*通过第三个参数、第四个参数等进行数组。
278*@返回数组合并后的数组(原始数组不变。)
279*@见合并
280      */
281公共静态函数合并数组($a,$b)
282     {
283$args=func_get_args();
284$res=数组移位($args);
285而(!空($args))
286         {
287$next=数组移位($args);
288 foreach($k=>v)
289             {
290如果(是_整数($k))
291 isset($res[$k])?$res[]=v:$res[$k]=v;
292其他if(is_数组($v)和isset($res[$k])和is_数组($res[$k]))
293$res[$k]=self::mergeArray($res[$k],$v);
294其他
295$res[$k]=$v;
296             }
297         }
298返回$res;
299     }
300
堆栈跟踪
#0  
–C:\xampp\htdocs\yiitest\protected\yii\framework\base\CModule.php(468):CMap::mergeArray(数组(“类”=>“CDbConnection”),1)
463 foreach($id=>$component的组件)
464         {
465 if($IApplicationComponent的组件实例)
466$this->setComponent($id,$component);
467 else if(isset($this->_componentConfig[$id])&&&$merge)
468$this->u componentConfig[$id]=CMap::mergeArray($this->u componentConfig[$id],$component);
469其他
470$this->_componentConfig[$id]=$component;
471         }
472     }
473
#1  
+C:\xampp\htdocs\yiitest\protected\yii\framework\base\CComponent.php(153):CModule->setComponents(数组(“用户”=>array(“allowAutoLogin”=>true,“类”=>RWebUser”),“phpThumb”=>array(“类”=>ext.ephpthhumb.epthumb”),“authManager”=>array(“类”=>RDbAuthManager”),“urlManager”=>array(“格式”=>path”,“规则”=>array(“/”=>“/view”、“//”=>“/”、“/”=>“/”)、…)
#2  
+C:\xampp\htdocs\yiitest\protected\yii\framework\base\CModule.php(483):CComponent->uu集(“组件”,数组(“用户”=>array(“allowAutoLogin”=>true,“类”=>“RWebUser”),“phpThumb”=>array(“类”=>“ext.ephthumb.epthumb”),“authManager”=>array(“类”=>“RDbAuthManager”),“管理器”=>array”(“格式”=>“路径”,“规则”=>数组(“/”=>“/view”、“/”=>“/”、“/”=>“/”)、…)
#3  
+C:\xampp\htdocs\yiitest\protected\yii\framework\base\capapplication.php(144):CModule->configure(数组(“名称”=>“学院管理系统”,“预加载”=>数组(“日志”),“导入”=>数组(“应用程序.模型”。,“应用程序.扩展.jtogglecolumn.*”,“应用程序.扩展.AjaxList.AjaxList”,“应用程序.组件”。,…),“模块”=>数组(“gii”=>数组(“class”=>“system.gii.GiiModule”,“password”=>“secure”,“generatorPaths”=>数组(“ext.gii-extended”),“ipFilters”=>数组(“127.0.0.1”,““::1”,“192.168.0.163”)),0=>“notification”,1=>“webservice”,“rights”=>数组(“install”=>false,“superuserName”=>“SuperAdmin”,“authenticatedName”=>“Authenticated”,“用户id列”=>“用户id”、…)、…)、…)、…)
#4  
+C:\xampp\htdocs\yiitest\protected\yii\framework\YiiBase.php(127):capapplication->\uu构造(“C:\xampp\htdocs\yiitest/protected/config/main.php”)
#5  
+C:\xampp\htdocs\yiitest\protected\yii\framework\YiiBase.php(100):YiiBase::createApplication(“CWebApplication”,“C:\xampp\htdocs\yiitest/protected/config/main.php”)
#6  
–C:\xampp\htdocs\yiitest\index.php(18):YiiBase::createWebApplication(“C:\xampp\htdocs\yiitest/protected/config/main.php”)
13
14//指定每个日志消息中应显示多少级别的调用堆栈
15已定义('yi_TRACE_LEVEL')或定义('yi_TRACE_LEVEL',3);
16
17需要一次(亿美元);
18 Yii::createWebApplication($config)->run();
19 ?>
20

第287行的函数
array\u shift()
返回了
null
,因此
$next
不是数组。
当然,
foreach()
需要一个数组。

在传递到循环之前验证该值。当数组为空时,将捕获该值

  $next=array_shift($args);
  if ($next != null) 
  {
     foreach($next as $k => $v)
     {
        // do things here
     }
  }

您确定要将数组传递给
foreach
loopno我不知道….请告诉我如何修改该错误??一步一步,因为我是PHP的新手,但我是新的..请告诉..我更改了什么以及在哪里..它似乎不是新手编写的代码。