我被要求处理别人用cakePHP创建的应用程序。我是cakePHP的新手。该应用程序显示以下错误
Notice(8):
if(isset($client[0]) && $client[0]['contacts']['type_of']==3 && $var=='clients_with_contacts' && $this->Paginator->current()==1){
echo '<td style="background:lightblue">'.$client[0]['Client'][$field].'</td>';
include - APP/View/Clients/index.ctp, line 90
View::_evaluate() - CORE/Cake/View/View.php, line 947
View::_render() - CORE/Cake/View/View.php, line 909
View::render() - CORE/Cake/View/View.php, line 471
Controller::render() - CORE/Cake/Controller/Controller.php, line 948
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 194
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 112
有很多代码。如果你能想到任何事情,请告诉我。
答案 0 :(得分:0)
一种可能的解决方案是在条件中检查变量'$ var'和'$ client [0] ['contacts'] ['type_of']',如下所示:
if(isset($client[0]['contacts']['type_of']) && $client[0]['contacts']['type_of']==3 && isset($var) && $var=='clients_with_contacts' && $this->Paginator->current()==1){
echo '<td style="background:lightblue">'.$client[0]['Client'][$field].'</td>';
}
答案 1 :(得分:0)
在ClientsController中,检查$ client,并通过以下方式正确传输$ var:
$this->set ('client', $variable1);
$this->set ('var', $variable2);
或
$this->set (array ('client' => $variable1, 'var' => $variable2));
如果是,请检查$client
数组的所有字段是否也存在。
同样在您的代码中,if语句也错过了}
。