Jump to content
Killersites Community

Recommended Posts

What does mean that variable is set or not set? (in PHP or general)

Does that means:

  • // no var declared
  • $var;
  • $var = 'Some fancy string';
  • $var = ""; //(empty string)

I dont know all fancy terms, but I do know when variable is defined, declared and all that, but I dont know what variable is set means.

Thanks in advance, nerdz!

Edited by Biske94

Share this post

Link to post
Share on other sites



isset() is a function in PHP that will return true if the variable, in this case, $var has been assigned a value. If the variable has been created but nothing assigned, has the value of null or undefined, it will return false. basically, isset($var) says is this variable safe to use or not. 


To explain the differences between a NULL value and an undefined

//test 1 is defined, but has a value of null. isset will return false, use causes no error.
$test1 = null;

echo "\n----------\n\n";

//test2 is defined with a string value. isset will return true
$test2 = "test";

echo "\n----------\n\n";

//test3 is not defined, isset returns false and use causes error.

Which will output:



string(4) "test"


Notice: Undefined variable: test3 in /in/Nmk0t on line 17


I hope this will help those who asked the same question as I :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now