April 15, 2018 —John Koster
The blank
function is used to determine if the provided value contains a value that is not null
, or a non empty value. It can be useful to check arguments supplied to functions for values without having to check many different types specifically. A value is considered blank or empty if any of the following conditions are true:
null
,0
,boolean
value,Countable
object and contains no items,empty
evaluates to true
The signature of the blank
function is:
1function blank(2 $value3);
The following example demonstrates the basic usage of the blank
function:
1// Set a value to null.2$testValue = null;3 4if (blank($testValue)) {5 // Perform some action when the value is blank.6} else {7 // Perform a different action when the8 // supplied value is not blank.9}
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.