php tutorial - PHP Empty Function - php programming - learn php - php code - php script
What is PHP empty functions - Purpose of empty function
Syntax to use empty function
Bool_var = empty ($variable_to_check);
click below button to copy the code. php tutorial - team
An example of using the empty function

An example with integer type variable

An empty example with array element

Why we use the empty function?
How to use PHP empty function
Bool_variable = empty ($variable_to_check_for_empty);
click below button to copy the code. php tutorial - team
- This is what the empty function takes as ‘empty’:
- If your string contains no characters or it is like this: Str = “”;
- Then this will be considered as empty.
- If a variable is not defined or does not exist, it will be considered as empty.
- If you have declared a variable and not given any value, this will still be considered as empty.
- If a Boolean variable is False, this is also considered as empty.
- The integer or float variable with 0 value are also considered as empty.
- A variable with NULL value is also taken as empty.
- An empty array is also taken as “empty”.