daGrevis Posted May 13, 2010 Report Share Posted May 13, 2010 Sveiki, Vai... if($x) {} ...būs pilnīgi tas pats, kas... if(isSet($x)) {} ...? Un esmu redzējis, ka daži dara šādi... if($x and isSet($x)) {} Kā būtu pareizāk? Quote Link to comment Share on other sites More sharing options...
bobsters Posted May 13, 2010 Report Share Posted May 13, 2010 (edited) isset -- Determine whether a variable is set bool isset ( mixed var [, mixed var [, ...]] ) Returns TRUE if varexists; FALSE otherwise. If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. Also note that a NULL byte ("\0") is not equivalent to the PHP NULL constant. Warning: isset() only works with variables as passing anything else will result in a parse error. For checking ifconstants are set use the defined() function. Edited May 13, 2010 by bobsters Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 13, 2010 Author Report Share Posted May 13, 2010 @bobsters Aha, izcel vēl trakāk. =) Es neprasu ko dara isSet(), labi to zinu, es prasu, vai if($x) {} dara to pašu, ko isSet()!!! [facepalm] Quote Link to comment Share on other sites More sharing options...
bobsters Posted May 13, 2010 Report Share Posted May 13, 2010 (edited) pārbaudi pats $x=0; if ($x){ echo "x ir uzlikts"; } if (isset($x)){ echo "X ir parbaudits ar isset"; } ar isset() viņš izvada tekstu parasts if($x) neizvada neko tātad secinam ka if ($x) nav jēgas Edited May 13, 2010 by bobsters Quote Link to comment Share on other sites More sharing options...
briedis Posted May 13, 2010 Report Share Posted May 13, 2010 nesapratu, ko bobster tur uzrakstīja, kaut aks dikti samurgots. Atbildi varat atrast te: http://www.php.net/manual/en/types.comparisons.php Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 13, 2010 Author Report Share Posted May 13, 2010 Paldies, briedis. Tādu atbildi arī cerēju saņemt... =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.