Grazza Posted March 5, 2008 Share Posted March 5, 2008 I am using the following piece of code to write a file $fp = fopen("template.doc", 'w+'); $str = "<html><body><table> <tr> <td>$address<br>$address2<br>$address3<br>$town<br>$county<br>$postcode</td> <td>$name</td> </tr> </table> </body></html>"; fwrite($fp, $str); fclose($fp); This works fine untill i try to use any HTML like align= or bgcolor or width or any perameters beyond the basics. Does anyone know a way I could get around this? The file I am writing needs to be quite well formated and must be in a msword file format. Link to comment https://forums.phpfreaks.com/topic/94514-using-html-within-the-fwrite-command/ Share on other sites More sharing options...
discomatt Posted March 5, 2008 Share Posted March 5, 2008 You are probably using double quotes when using the align= rule... You have to escape them (\") in this case because you use double quotes to define the variable ($var = "something")... You can either use single quotes ($var = 'something') or use the heredoc definition, as so: $var = <<<XYZABC I can put anything in here i want including single ' and double " quotes. Makes life EASY for stuff like this XYZABC; or $var = <<<aNyThiNgUniQuE Yay Flexibility! aNyThiNgUniQuE; Link to comment https://forums.phpfreaks.com/topic/94514-using-html-within-the-fwrite-command/#findComment-483979 Share on other sites More sharing options...
Grazza Posted March 5, 2008 Author Share Posted March 5, 2008 Thanks thats very helpfull Link to comment https://forums.phpfreaks.com/topic/94514-using-html-within-the-fwrite-command/#findComment-483981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.