I would like to append a php command to another file to appear exactly as the $string contents shows between the quotes. The idea is shown below:
$string = "<?php include_once $_SERVER['DOCUMENT_ROOT']./content/single_page_loader.php; ?>";
file_put_contents($existing_file, $string.PHP_EOL, FILE_APPEND);//append to end
The <?php and other php commands seem to produce errors such as:
Parse error: syntax error, unexpected string content "", expecting "-" or identifier or variable or number in C:wamp64wwwdev.xxxxxx.comtest.php on line 40
How can this be achieved?
Thanks!