php - What's isset($_POST[''])?_POST['']:false -


what isset($_post['usrnm'])?$_post['usrnm']:false; do? better thanisset($_post['usrnm']) {} ?

it ternary operator. translates to:

if (isset($_post['usrnm']))   $username = $_post['usrnm'] else   $username = false; 

the above code or below one:

isset($_post['usrnm'])?$_post['usrnm']:false; 
  1. checks if $_post['usrnm'] variable has been set (can set form through post).
  2. if set, $username value set. else, set false.

second question

isset($_post['usrnm']) {} 

the above code looks syntax error.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -