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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -