Greetings!
Long time off and on user of PHP, but not a ‘master coder’ by any means.
I want to read an html file with file_get_contents (which works fine) into a variable and then use str_replace to replace a string. Apparently php is sensitive to some characters in the HTML code and causes the str_replace to not work. Example:
$dest = “http://localhost/”;
$page = ($_REQUEST[‘page’]);
$pagepath = $dest.$page; // the full path to the html page
$username = ($_REQUEST[‘username’]); //the username is passed
$doc = file_get_contents($pagepath); // the html page is read into doc (This works fine)
str_replace("%%USERNAME%%",$password,$doc);
exit($doc);
This should return the page with the %%USERNAME%% replaced with the $username, but no change to $doc seems to be made.
What is the best/recommend way to do a ‘find/replace’ in an html file?
Have fun,
Paxton