I'm attempting to create an automatic installer for a system I have created, but the ONLY issue is the generation of a php file, in which variables simply do not show up.
Here's my code to create the file
<?php
$content = " <?php
$sqlHost = '".$host."';
$sqlUser = '".$user."';
$sqlPass = '".$pass."';
$sqlDatabase = '".$db."';
$sqlTables = array('donate_categories', 'donate_items', 'donate_claim', 'donate_admin');
$connection = new PDO('mysql:host='.$sqlHost.';dbname='.$sqlDatabase.';charset-utf8', $sqlUser, $sqlPass);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>";
$fp = fopen("connection.php", "wb");
fwrite($fp, $content);
$fclose($fp);
?>
as you can see there's php code wrapped in a string there; However the output is a little strange...
<?php
= 'localhost';
= 'root';
= '';
= 'test';
= array('donate_categories', 'donate_items', 'donate_claim', 'donate_admin');
= new PDO('mysql:host='..';dbname='..';charset-utf8', , );
(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
None of the variables are there, and I've looked up possible issues with this, but I haven't found any.
error_reporting(E_ALL);. Double quotes interpolate variables.$symbols (or switching the double quotes to single quotes), but why would you want to do this? What exactly is the point of using PHP code generate more PHP code?$connectionwould still need\$escaping though.inioryamlfile.