tallberg Posted November 11, 2007 Share Posted November 11, 2007 Ive tryed to understand this before but still not sure. $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode']: ''; Ive never come across a tutorial with the use of ? and : is it saying that if the $HTTP_POST_VARS['mode'] is set then that is what $mode equales and if not $mode equales a blank string? Thanks if any one can help me understand this. Link to comment https://forums.phpfreaks.com/topic/76845-solved-mode-issethttp_post_varsmode-http_post_varsmode/ Share on other sites More sharing options...
redbullmarky Posted November 11, 2007 Share Posted November 11, 2007 the ? ternary operator, and is pretty much an equivalent of if/else. so your code converted to the if/else way would be: <?php if (isset($HTTP_POST_VARS['mode'])) { $mode = $HTTP_POST_VARS['mode']; } else { $mode = ''; } ?> the bit before the ? is the condition. the next bit is the value to return if the condition is true, the last bit if the condition is false. on another note, i'd recommend using $_POST instead of $HTTP_POST_VARS due to the latter being deprecated. Hope that helps Cheers Mark Link to comment https://forums.phpfreaks.com/topic/76845-solved-mode-issethttp_post_varsmode-http_post_varsmode/#findComment-389046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.