AgerNic.com
Start write and run your php code online
HOME Editor | PHP Exemples | PHP Functions |
WEB TEMPLATES | EXAMPLES
PHP Tutorial
PHP empty() Function, run and write PHP code.

PHP empty() Function - online editor.

The empty() function is an inbuilt function in PHP which is used to check if a variable is empty or not.

Syntax:
define(name,value,case_insensitive);

Example :
empty() - returns true if a variable is empty.

 <?php 
// PHP empty() Function code to demonstrate working of empty()
$evar1 = 0;
$evar2 = 0.0;
$evar3 = "0";
$evar4 = NULL;
$evar5 = false;
$evar6 = array();
$evar7 = "";
$evar9 = 5;
echo "<pre>";
// for value 0 as integer
echo "1. ";
empty($evar1) ? print_r("True\n") : print_r("False\n");

// for value 0.0 as float
echo "2. ";
empty($evar2) ? print_r("True\n") : print_r("False\n");

// for value 0 as string
echo "3. ";
empty($evar3) ? print_r("True\n") : print_r("False\n");

// for value Null
echo "4. ";
empty($evar4) ? print_r("True\n") : print_r("False\n");

// for value false
echo "5. ";
empty($evar5) ? print_r("True\n") : print_r("False\n");

// for array
echo "6. ";
empty($evar6) ? print_r("True\n") : print_r("False\n");

// for empty string
echo "7. ";
empty($evar7) ? print_r("True\n") : print_r("False\n");

// for not declare $evar8
echo "8. ";
empty($evar8) ? print_r("True\n") : print_r("False\n");

// for value 5 as integer, this not empty
echo "9. ";
empty($evar9) ? print_r("True\n") : print_r("False\n");
echo "</pre>";
?>



Tags:
PHP empty() Function 8

PHP empty() Function

PHP Functons
PHP count() Function

PHP define() function

PHP empty() Function

PHP explode() function

PHP html_entity_decode() function

PHP htmlentities() function

PHP htmlspecialchars_decode() function

PHP htmlspecialchars() function

PHP implode() function

PHP isset() Function

PHP lcfirst() function

PHP ltrim() function

PHP md5() function

PHP print() function

PHP printf() function

PHP rtrim() function

PHP similar_text() function

PHP str_repeat() function

PHP str_replace() function

PHP str_split() function

PHP strcmp() function

PHP strip_tags() function

PHP strlen online function

PHP strrchr() Function

PHP strstr() function

PHP strtolower() function

PHP strtoupper() function

PHP substr() function

PHP trim() function

PHP ucfirst() function