Jump to content

how can I use isset values?


co.ador

Recommended Posts

Can you guys explain me what does this mean?

 

$cat = isset($_GET['subject']) &&
is_numeric($_GET['subject'])?$_GET['subject']:null;
$prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null;
$menu_type = isset($_GET['menu_type']) && is_string($_GET['menu_type'])?$_GET['menu_type']:null

 

And how can I use this values, give me as much opinios as you can.

 

I want to know how can I use a value when is isset($_GET,  is_numeric($_GET, $_GET and null.

 

one example would be

$class = !is_null($cat) && $cat==$row['id']?' class="selected"':''

Thank you..

Link to comment
https://forums.phpfreaks.com/topic/158836-how-can-i-use-isset-values/
Share on other sites

Please refer to the manual for what each of these functions do.

 

The code there is equivalent to this:

 

if(isset($_GET['subject'] && is_numeric($_GET['subject']))
{
   $cat = $_GET['subject'];
}
else
{
   $cat = null;
}

if(isset($_GET['menu']) && is_numeric($_GET['menu']))
{
   $prod = $_GET['menu'];
}
else
{
   $prod = null;
}

if(isset($_GET['menu_type']) && is_string($_GET['menu_type']))
{
   $menu_type= $_GET['menu_type'];
}
else 
{
   $menu_type = null;
}
?>

 

The only difference is that it's using ternary operators.

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.