Page 1 of 1

Loading an HTML page

Posted: Thu Mar 15, 2007 3:37 pm
by mavedog21
Hello,

I can't seem to load an html page.

I know this is probably the most basic question but I can't seem to
find a tutorial or instructions besides the php.net's loadHTMLFile
which seems to throw up a bunch of errors.

I test at home using php5 so I can't test until later but here is
what I've already tried, it's in an if statment

php5 code snippet

Code: Select all

if(!empty($myVariable)){
    $doc = new DOMDocument();
    $doc->loadHTMLFile("filename.html");
             echo $doc->saveHTML();
}else{
     $doc = new DOMDocument();
     $doc->loadHTMLFile("filename.html");
   echo $doc->saveHTML();
}
This throws up errors and then the HMTL page requested underneth the errors.
I can't remember what exactly the errors are because I'm at work but I'm curious if I'm even on the right track?

Should I be using fopen which didn't seem to work either.

If you have some quidance or know of a script online I can look at that would be cool.

thanks, sorry it's kinda vague I'm at work trying to figure this out on my down time.

sky

Posted: Thu Mar 15, 2007 3:52 pm
by nickvd
What errors?

Posted: Thu Mar 15, 2007 5:35 pm
by s.dot
If you're looking for any solution, you could use file_get_contents()

Code: Select all

echo file_get_contents('page.html');

Posted: Fri Mar 16, 2007 10:57 am
by mavedog21
For reasons I don't know it justed started working without any problems.
The same code I tried before just started working. I have no clue why.

thanks for the other option scottayy.

sky