Jump to content
php.lv forumi

isSet()


daGrevis

Recommended Posts

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?

Link to comment
Share on other sites

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 by bobsters
Link to comment
Share on other sites

@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]

Link to comment
Share on other sites

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 by bobsters
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...