I am trying to write php script in a file.It was sure to get Parsing error on that.Help me assign php code to a php variable so i can write it on code.
<?php
$myFile = "testFile1.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "<?php some php code with functions ?>";
fwrite($fh, $stringData);
fclose($fh);
?>
For example:
So just use single quotes to make sure php won’t parse vars as php vars themselves, and use concatenation to put var value in the file. You also probably may use var_export($var, true) function in some cases.