Jump to content

Recommended Posts

$name    = isset($_POST['name']) ? $_POST['name'] : "";

 

I have seen this in some sample forms online and I am just trying to make sure that I am understanding it properly.  I am trying to learn the language to build smarter php forms.  Any help would be great. 

 

 

isset -- checks to see if the variable has a value........Therefore, isset($_POST['name']) is checking to see that ($_POST['name']) has a value

 

? - What does the ? mean in this statement

 

$_POST['name'] :""  --- What does the :"" mean in this statement

 

Thank you in advance for your help

 

Link to comment
https://forums.phpfreaks.com/topic/104946-solved-what-exactly-does-this-mean/
Share on other sites

Thanks for the quick response so

$name    = isset($_POST['name']) ? $_POST['name'] : "";

 

means:

if $name has a value then set the value to what was inputed in $_POST['name']

if $name has no value then set it equal to nothing (")

 

You rock...thank you!!!

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.