Hi there, I'm trying to write a html file via php, the html file just contains standard html. I'm doing this with fopen / fwrite / fclose. $fh = fopen($file, 'w') or die("can't open file"); $stringData = "$html"; fwrite($fh, $stringData); fclose($fh); PHP: However when I open the html file it have a \ in front of all the " which causes a problem. Fx: <td width=\"25px\"> HTML: And what I want it to be: <td width="25px"> HTML: Anyone know how I can fix this problem? Thanks
I'm assumming you get the $html from a form? - theirs a possibility the slashes are caused by magic_quotes. Theirfore change: fwrite($fh, $stringData); PHP: to: fwrite($fh, stripslashes($stringData)); PHP:
ah of course, actually thought I had it disabled. Thanks mate Anyway wrote this if anyone is interested should work with any configuration: $fh = fopen($file, 'w') or die("can't open file"); $magic_quotes_active = get_magic_quotes_gpc(); if ($magic_quotes_active){ $stringData = stripslashes($html); } else { $stringData = $html; } fwrite($fh, $stringData); fclose($fh); PHP: