PHP question mark operator and string concatenation PHP question mark operator and string concatenation codeigniter codeigniter

PHP question mark operator and string concatenation


It does support it, just put some parenthesis around it:

$output_string .= "<td>".(($row->isactive == "0") ? "Activated":"Deactivated")."</td>";


You're not putting enough parentheses. Try this instead:

$output_string .= "<td>".(($row->isactive == "0") ? "Activated":"Deactivated")."</td>";

Note the extra set of parentheses.

If you just put:

$output_string .= "<td>".($row->isactive == "0") ? "Activated":"Deactivated"."</td>";

The PHP interpreter will try and display $row->isactive == "0", so for it to do what you want, you must enclose it in an extra set of parentheses.


Not like that,but after the ":" operator your

:"Deactivated"."</td>";

should be treated as single statement for false,if you want to got this try like

$output_string .= "<td>".(($row->isactive == "0") ? "Activated":"Deactivated")."</td>";