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. Quote Link to comment 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; Quote Link to comment Share on other sites More sharing options...
Grazza Posted March 5, 2008 Author Share Posted March 5, 2008 Thanks thats very helpfull Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.