Jump to content

write PHP code using fwrite()


nadeemshafi9

Recommended Posts

hi guys

i need to write the entire following code to a file using fwrite()

[code]$data = "".
"<?php".
"$i = 'hello'".
"print $i;".
"?>";

$i=fopen(file)
fwrite($i,$data)[/code]

i tried leading and trailing backslashes and double backslashes they reduce the prob but dont eradicate it. the slashes appear in the file

thanks for any help

Nadeem
Link to comment
https://forums.phpfreaks.com/topic/18830-write-php-code-using-fwrite/
Share on other sites

hi i tried ur sugestion it didnt work but i read up on the heredoc syntax on php.net and it said in cases like mine i can also use single quotes which work well.

thancks though this heredoc syntax looks interesting and is new to me iim glad u brought it up

thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.