Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.