-3

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 ?> 
';
Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95

2 Answers2

0

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

Ayaz Ali Shah
  • 3,453
  • 9
  • 36
  • 68
0

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.

Michał Skrzypek
  • 699
  • 4
  • 14