0

Does not work with this url. What is the problem? Get error - PHP Notice: Trying to get property of non-object

<?php
include ('config.php');
include('simple_html_2012.php');
echo file_get_html('http://www.localhost/test/test.html')->plaintext; 
?>

if trying to parse google.com, it all works.

5
  • www.localhost? With leading www.? Commented Mar 10, 2014 at 9:26
  • Still Trying to get property of non-object in /var/www/test/index.php on line 4 Commented Mar 10, 2014 at 9:33
  • 1) Is the URL valid? (i.e., can you paste it in a browser and get the site?) 2) Have you disabled allow_url_fopen? Commented Mar 10, 2014 at 9:36
  • NetBeans tells me OutOfMemoryError Commented Mar 10, 2014 at 9:52
  • Do you mean that your IDE is crashing or that you are getting a different PHP error message depending on how you run the script. The former is quite irrelevant IMHO, the latter merits some details. Commented Mar 10, 2014 at 10:00

2 Answers 2

2
echo file_get_html('http://localhost/test/test.html')->plaintext;

or

echo file_get_html('http://127.0.0.1/test/test.html')->plaintext;
Sign up to request clarification or add additional context in comments.

2 Comments

Still Trying to get property of non-object in /var/www/test/index.php on line 4
Have you tried using file_get_contents instead of file_get_html? php.net/manual/en/function.file-get-contents.php
0

may be helpfull:

    if($source = file_get_contents("http://localhost/test/test.html"))
    {
        $html = str_get_html($source);
        echo $html->plaintext;
    }
    else
    {
        echo "Something wrong!";
    }

2 Comments

if ($html->innertext != null) { echo 'good'; } else { echo "bad"; } // $html is null
NetBeans tells me OutOfMemoryError

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.