Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.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 如何忽略Kohana中的通知或检查它是否为对象?我';我做错了?_Php_Xpath_Kohana - Fatal编程技术网

Php 如何忽略Kohana中的通知或检查它是否为对象?我';我做错了?

Php 如何忽略Kohana中的通知或检查它是否为对象?我';我做错了?,php,xpath,kohana,Php,Xpath,Kohana,如何忽略Kohana中的通知或检查它是否是对象?只需使用isSet($dish\u id->item(0)->nodeValue)通知/警告就可以了。您不应该忽略错误。你应该把它们修好。 $dom=new DOMDocument(); @$dom->loadHTML($cl); $xpath=new DOMXpath($dom); $dish_l=$xpath->query("/html/body/div/table[5]/tr/td/div/div"); echo $dish_l

如何忽略Kohana中的通知或检查它是否是对象?

只需使用
isSet($dish\u id->item(0)->nodeValue)
通知/警告就可以了。您不应该忽略错误。你应该把它们修好。
$dom=new DOMDocument();
@$dom->loadHTML($cl);
$xpath=new DOMXpath($dom);

$dish_l=$xpath->query("/html/body/div/table[5]/tr/td/div/div");
echo $dish_l->length;

for($index=0;$index<$dish_l->length;$index++)
{
    if( ($dish_id->item(0)->nodeValue) ) //I no need empty <div> blocks and this idea works perfect
    {   

    }
}
for($index=0;$index<$dish_l->length;$index++)
{
   if(!is_object ($dish_id ) )//but it is not works
     {
     }
     else
     {
        if( ($dish_id->item(0)->nodeValue) ) 
        {   
        }    
     }
}