I am trying to add if statemenet into $html variable. But it see php as a html tag. how can add this statement. Thanks
$html = '
<?php if (x=y):?>
<div>
Help me )
</div>
<?php endif ?>
';
I am trying to add if statemenet into $html variable. But it see php as a html tag. how can add this statement. Thanks
$html = '
<?php if (x=y):?>
<div>
Help me )
</div>
<?php endif ?>
';
Try following
$html = '';
if(x==y):
$html .= '<div> Help me )</div>';
endif;
You can do without closing php tags.
Edited
After @MichałSkrzypek comment I have edited and fix mistake in if statement
What you are trying to do is impossible. If you would want to echo the var, you would put <?php
inside of <?php
, which must result in an error. Only add
<div>
Help me )
</div>
to a var.