isset() vs check if exists for a variable in PHP -


how following 2 function calls compare check if variable exists call or post call ?

if(isset($_get['var'])) if($_get['var']) 

both job without isset() warning :

php notice: undefined index: var on @ line xx

update $_get not $get. know has nothing get/post. discussing variable check instead of http method. thanks.

$_get[''] retrieved browser, if had following: www.hello.com/index.php?var=hello

you use:

if(isset($_get['var'])) { echo $_get['var']; // print out hello } 

using isset() stop undefined index error, if had www.hello.com/index.php example not see error though var not set.

posts when 1 page posts information another, method same using $_post[''] instead of $_get['']. example have form posting information:

<form method="post" action="anotherpage.php">     <label></label>     <input type="text" name="text"> </form> 

in anotherpage.php information like:

$text = isset($_post['text']); echo $text; // echo ever input text field on other page 

in nut shell, putting $_get['name'] if name not set error. using isset($_get['name']) check var name has value before continuing.

not sure if after, question best guess @ answer


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -