# Why is my ternary expression not functioning?

I am attempting to set a flag to show or hide a web page component, yet it constantly presents also when the expression is incorrect.

$canMerge = ($condition1 && $condition2) ? 'true' : 'false'; ... <?php if ($canMerge) { ?>Stuff<?php } ?>


What's up?

0
2019-05-03 17:51:40
Source Share
$canMerge = ($condition1 && $condition2) ? true : false;  0 2019-05-07 18:19:15 Source This is damaged due to the fact that 'incorrect' as a string will certainly review to real as a boolean. Nonetheless, this is an unnecessary ternary expression, due to the fact that the resulting values are straightforward real and also incorrect. This would certainly be equal : $canMerge = ($condition1 &&$condition2);