Jump to content

Just some help understanding


dragonusthei

Recommended Posts

Hello

I was just wondering if someone could explane some php for me

In 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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.