Using heredoc or nowdoc, how could I create $sting?
$x_value=2;
$string='$x='.$x_value.';';
exit($string); //$x=2;
PS. I am aware of the slippery slope of script like this
Using heredoc or nowdoc, how could I create $sting?
$x_value=2;
$string='$x='.$x_value.';';
exit($string); //$x=2;
PS. I am aware of the slippery slope of script like this
Per Mark's comment, the value which shouldn't be parsed should be escaped:
$x_value=2;
$string = <<<EOD
\$x=$x_value;
EOD;
exit($string);