Star Hoster
Photoshop Tutorials
Anonymous Web Surfing
Funny Jokes
Myspace Friends
Open Treasure Chest
Building in Paradise


July 13, 2008

Php Variables Test Functions

Filed under: Advanced PHP Tutorials — phpdeveloper @ 9:54 am

Php provides isset, unset and empty that can help you when you use variables in php programming and coding. These variables will give you the status of a variable, if it is in use, created, or when you want to get rid of the variable.

isset()
Isset is used to show the user if a variable has be created. Isset() will return the value of 1, if the variable is created. If the variable is not created, nothing will be returned by Isset.

echo isset($myVar);

empty()
Empty, is logically opposite to isset, and it provided a little more information on the variable.
If the variable is not created empty return the value of 1, if the variable is define and has the value (0, or “” (null/empty string)) empty returned the value of 1 as well. However if the variable is defined empty does not return any values.

echo empty($myVar);

unset()
Unlike isset and empty, which just returns a value, unset acts on the variable. Unset cleared the varaible from memory and unallocated the variable. The variable name and the value of the variable is completed erased when using unset.
Thus great care should be used when using the function unset, and you should be sure that you dont require that variable or its vale anywhere else in the program.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.