How to store PHP code inside heredoc variable? -
i store following code inside heredoc variable:
<?php $var = 'test'; echo $var; ?> like that:
$hered = <<<hered <?php $var = 'test'; echo $var; ?> hered; the problem heredoc works double quotes "" - means each dollar sign ($)have replaced \$...
is there way use heredoc without performing such operation?
yes, there is. check out nowdoc syntax:
$hello = 'hey'; $echo <<<'eos' $hello world! eos; //output: $hello world
Comments
Post a Comment