I am making some scripts that will make my PHP scripts for me, basicly its like an install process that will ask me questions and then write the PHP files that I need based on my questions. I have gotten it to work but wanted to see if this is the best way to do it.
<?php
$var = '<?php
echo "Hello World";
$var = 1;
echo $var. **<a href="index.php">Click Here</a>**;
?>';
$var = str_replace("**", "'", $var);
$myFile = "testing.php";
$fh = fopen($myFile, 'w') or die("can't open file");
if(fwrite($fh, $var)) {
echo "Writen to file worked";
}
fclose($fh);
?>
The reason for the ** is to not break the $var = statment. Let me know if this looks right, it is working but I just want to make sure there is no better way of doing it.