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.
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');