PHP - Simple HTML Dom parser - 500 Server Error
I'm running a simple Cent开发者_C百科OS 5.5 server with PHP 5.2.10. I'm trying to use PHP Simple HTML Dom parser but I get a 500 Server Error. Here is the script:
<?php
include_once('simple_html_dom.php');
$html = file_get_html('http://www.google.com/');
As you can see, I'm not even doing anything with the parser yet except trying to open a url. And that file_get_html
is resulting in a 500 Server Error.
I don't see any errors showing up in the httpd error log. So I'm not sure where to look to figure out the problem. The only PHP requirements for Simple HTML Dom parser seem to be PHP 5+ (check) and php allow_url_fopen = On
(check).
Since version 5.2, PHP will generate HTTP 500 response if there is fatal error, and display_errors is off. Turn in on to see the error, that stops the execution of the script. Maybe file is not included (wrong permissions, path) and file_get_html() is not defined, or maybe file_get_html() produces a fatal error.
try this file_get_contents
maybe it's because the "php-mbstring" module did not installed ? you could using ini_set('display_errors', 'On');
to check this out .
Per Vitor's suggestion, I changed solved this problem by changing file_get_html to file_get_contents. Since I wanted to use the 'find' feature in simple_html_dom, I had to then convert the string to an object:
$string = file_get_contents(http://thedeadfallproject.com/)
$object = new simple_html_dom();
$object->load($string); // Load HTML from a string
精彩评论