user3401012
user3401012

Reputation: 11

Simple php dom parser doesn't work with local url

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.

Upvotes: 0

Views: 629

Answers (2)

kivlara
kivlara

Reputation: 63

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!";
    }

Upvotes: 0

Nazaret2005
Nazaret2005

Reputation: 373

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

or

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

Upvotes: 3

Related Questions