PHP如果函数内部变量

How can I add if function in my PHP code below :

$html = 'blabla
'.if($a = $b).'
{
}
';

When I run that code, it show error like this :

Parse error: syntax error, unexpected 'if' (T_IF) in...

Please help to advice.

Thanks.

You need to use a ternary operator.

Example:

$html = 'blabla' . ($a == $b ? 'write something' : 'or something else');

use append again to string and use == to compare like

$html = 'blabla';
if($a == $b){
$html .='yes';
}

or use ternary operator like @Viktor Svensson answer

You probably want to do something like this.

<?php

$html = 'Your order was ';

if ($order->status === 'success') { // I don't know just doing something random
    $html .= ' successful';
} else {
    $html .= ' unsuccessful';
}