Timothy Coetzee Timothy Coetzee - 8 months ago 53
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?


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.