php if empty
snippet in php

php code to check if variable is null

user9762

if(empty($var1)){
    echo 'This line is printed, because the $var1 is empty.';
}

jquery check if empty object

user7954

jQuery.isEmptyObject( object );

Example:
jQuery.isEmptyObject({}) // true
jQuery.isEmptyObject({ foo: "bar" }) // false

php if empty

user7581


<?php

  $a = 0;

// True because $a is empty
if (empty($a)) {
  echo 
  "Variable 'a' is empty.<br>";
}

// True because $a is set
if (isset($a)) 
  {
  echo "Variable 'a' is set";
}
?>
 

php check for empty string

user5995

if (empty($var)) {
    echo '$var is either 0, empty, or not set at all';
}

php check empty variable

user9418

empty var php

is empty php

user9545

empty($var)