I am wondering if it is possible to write php code to a file. For example:
fwrite($handle, "<?php $var = $var2 ?>");
I would like it produce the exact string in the file and not the eval'ed code. Is this possible?
I am currently getting the following output (where $var = 1 and $var2 = 2):
<?php 1 = 2 ?>
Whereas I want the actual string:
<?php $var = $var2 ?>
Thanks for the help
You can use single quotes instead of double quotes, which do not expand inline variable names:
fwrite($handle, '<?php $var = $var2 ?>');
Just escape the $ symbol
<?php
fwrite($handle, "<?php \$var = \$var2 ?>");
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With