• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP Question: Read HTML Source And Assign To Variable?

Superwormy

Golden Member
PHP Question: Read HTML Source And Assign To Variable?

How would I do that? Assign the source of a seperate HTML file to a variable...
 
$filename = "/usr/local/something.html"; or $filename = "http://mysite.net/myfile.html";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename)); or $contents = fread ($fd, somelength);
fclose ($fd);

filesize only works when opening a file locally. If you open a URL as a file, you need to manually specify a length and may have to check if you read everything.

This is the easiest way that comes to mind.
 
Back
Top