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! Quote Link to comment Share on other sites More sharing options...
requinix Posted June 7, 2013 Share Posted June 7, 2013 (edited) It's the ternary operator and works like if (isset($mValues['Result'])) { // X ? ___ : ___ $temp = $mValues['Result']; // ___ ? Y : ___ } else { $temp = 0; // ___ ? ___ : Z } $Result = $temp; Edited June 7, 2013 by requinix Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.