Timothy Coetzee Timothy Coetzee - 1 year ago 113
PHP Question

PHP - check if variable is undefined

Consider this jquery statment

isTouch = document.createTouch !== undefined

I would like to know if we have a similar statement in PHP, not being isset() but literally checking for an undefined value, something like:

$isTouch != ""

Is there something similar as the above in PHP?

Answer Source

An another way is simply :

    echo "Yes 1";
    echo "Yes 2";

$test = "hello";

    echo "Yes 3";

Will return :

"Yes 3"

The best way is to use isset(), otherway you can have an error like "undefined $test".

You can do it like this :

if( isset($test) && ($test!=null) )

You'll not have any error because the first condition isn't accepted.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download