Quick simple question, is it possible to do an if statement inside of a php assignment statement so that you can switch what would be assigned?
IE: Inside of a wordpress PHP function that already works
$example.='
<div id="test-'.$num.'">
<a href="http://google.com">Google</a>
</div>';
The following doesn’t work (gives an IF parse error)
$example.='
<div id="test-'.$num.'">
'if($num == 2)'
<a href="http://yahoo.com">Yahoo</a>
'else' <a href="http://google.com">Google</a>
</div>';
instead you could have done:
You can concatenate the code:-
check the code: