TrimBalim Posted June 7, 2013 Share Posted June 7, 2013 Hey everyone, I'm working on some php code and for the first time, I've seen some syntax that goes as follows: $Result = isset($mValues['Result']) ? $mValues['Result'] : 0; I'm not exactly sure what this does, but I can take a stab at it: it checks if the value $mValues['Result'] is set, the ? says to check if it's true, and if it is, set $mValues['Result'] to 0? Thanks in advance for any help! Link to comment https://forums.phpfreaks.com/topic/278910-php-syntax/ Share on other sites More sharing options...
requinix Posted June 7, 2013 Share Posted June 7, 2013 It's the ternary operator and works like if (isset($mValues['Result'])) { // X ? ___ : ___ $temp = $mValues['Result']; // ___ ? Y : ___ } else { $temp = 0; // ___ ? ___ : Z } $Result = $temp; Link to comment https://forums.phpfreaks.com/topic/278910-php-syntax/#findComment-1434748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.