Reputation: 55
I'm not sure how the comparison operation of the array node works in relation to the assignment of 'true' to the same array node. Is this some alternate usage of the Ternary syntax? Either an explanation or a link to the PHP reference (I don't even know how to search for this) would be helpful. Thanks in advance.
// RESOLVE myvar TO BOOLEAN
$atts['myvar'] = 'true' == $atts['myvar'];
Upvotes: 0
Views: 40
Reputation: 75645
You should read this like that:
$atts['myvar'] = ('true' == $atts['myvar']);
(saving on brackets is never worth a penny). When run, it will compare actual content of $atts['myvar']
with string true
(4 letters) and then overwrite $atts['myvar']
with result of the comparison, which will be boolean by then. If it equals to string "true" then result is boolean true
, for anything else it will become boolean false
. In other words, it converts "string boolean" to regular boolean.
Upvotes: 2