dragonusthei Posted June 5, 2006 Share Posted June 5, 2006 HelloI was just wondering if someone could explane some php for meIn the following:$action = isset($_GET['action']) ? $_GET['action'] : '';What would the ? mark do? what does a question mark do in PHP?What would the : do what does : serve to do in PHP?Thank you [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Link to comment https://forums.phpfreaks.com/topic/11275-just-some-help-understanding/ Share on other sites More sharing options...
AndyB Posted June 5, 2006 Share Posted June 5, 2006 ternary operator - faster than if then elses tutorial explains - [a href=\"http://www.totallyphp.co.uk/tutorials/using_if_else_ternary_operators.htm\" target=\"_blank\"]http://www.totallyphp.co.uk/tutorials/usin...y_operators.htm[/a] Link to comment https://forums.phpfreaks.com/topic/11275-just-some-help-understanding/#findComment-42214 Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 $action = isset($_GET['action']) ? $_GET['action'] : '';$action = condition ? if condition is true, do this : if it is not true, do this;basically you are setting the $action to a certain value, depending on whether $_GET['action'] exists or not. if it does, then it sets $action to $_GET['action']. if it is not, then it sets it to ''it is the same thing as doing this:[code]if (isset($_GET['action']) { $action = $_GET['action'];} else { $action = '';}[/code]edit: andyb beated me Link to comment https://forums.phpfreaks.com/topic/11275-just-some-help-understanding/#findComment-42216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.