redarrow Posted September 10, 2006 Share Posted September 10, 2006 i have seen meny people useing this format of programming but what does the ? do cheers.advance thank you.this code an example with the ? in the syntex i would like to know what it does incase it is inportant and i am missing somethink here?[code]<?phpif(isset($record['name'] ? $record['password'])){do some think}?>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 10, 2006 Share Posted September 10, 2006 I think you are referring to the ternary operator, which has the format$var = ($some_condition) ? $value_if_condition_true : $value_if_false ;which is shorthand for[code]if ($some_condition) { $var = $value_if_condition_true;}else { $var = $value_if_false;}[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 10, 2006 Author Share Posted September 10, 2006 Thank you i get it cheers. Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 10, 2006 Share Posted September 10, 2006 I use it when I am naming one var on the outcomefor example to check a page number$page_num = is_numeric($_GET["page"] ? $_GET["page"] : 1;$page_num = str_len($_GET["page"] <= 3 ? $page_num : 1;Basicly, what you can put in the if statementif(statement){can go thereArgument ?(then) :(else) 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.