Can we use PHP iF Statements in <<<EOD syntax code -
i using <<<eod
output data. question how use php if condition inside <<<eod
syntax? can use this
<<<eod <h3>caption</h3> if(isset($variablename)) { echo "...some text"; } else { echo "...some text"; } eod;
no, because inside <<<
block (known "heredoc") string.
if write code in question, you'll writing string containing php code, isn't want (i hope).
do logic outside of heredoc, , use plain variables inside it:
if(isset($variablename)) { $outputvar = "...some text"; } else { $outputvar = "...some text"; } print <<<eod <h3>caption</h3> {$outputvar} eod;
Comments
Post a Comment