views:

83

answers:

3

I am using the loadhtml function (http://php.net/manual/en/domdocument.loadhtml.phpt) to load up an external .html file. When I load it, it "tidy's" up my code, which, I don't want. I do NOT want a full HTML document, I only want html snippets in my .html, and I don't want the loadhtml file to try to make it valid html, because I don't want it to.

Is there a better function to load up a .html file so that it does not tidy up the code?!

+3  A: 

If you want to just put the HTML into a string, you can just use:

$file1 = file_get_contents("file.html");
Dumb Guy
A: 

LoadHTML puts your html file data into a DOM structure.

If it is not really HTML (snippets aren't) then you can't really make a DOM structure -- but that is what you asked for.

Now, the first question comment asked what you wanted to do once this data was loaded, so either you have a good answer for that which will point us in a new direction, or the answer is simply NO.

Don
A: 

To store:

$contents = file_get_contents('example.html');

To output:

readfile('example.html');
enbuyukfener