How to solve Fatal error in php

爷,独闯天下 提交于 2019-12-02 20:19:10

问题


While running the codes on local host it is showing an error of--

( ! ) Fatal error: Call to a member function find() on a non-object in 
C:\wamp\www\crawler_based_search_engine\ajax_requests.php on line 130

Call Stack

#   Time    Memory  Function    Location
1   0.0151  162928  {main}( )   ..\ajax_requests.php:0

the codes from line 130 and beyond is as follows

            $html = file_get_html($file_name);
            // Find all links 
            foreach($html->find('a') as $element) //--this is line no 130
            {
                $url = $element->href;
                $index = strpos($url,'q=https://');
                if($index > 0)
                {
                    $index2 = strpos($url,'webcache');
                    if($index2 === false)
                    {
                        $index2 = strpos($url,'sa=U');
                        $url = substr($element->href,$index+2,$index2-$index-3);
                        echo "<a href='$url'>$url</a>";
                        echo '<hr/>';
                    }
                }
            }

because of this error my program is not fetching the links from the google

来源:https://stackoverflow.com/questions/28252078/how-to-solve-fatal-error-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!