April 15, 2018 —John Koster
The filled
helper function is the logical opposite of the blank
helper function, and can be used to quickly determine if the provided value has a non-null, or non-empty value. The provided $value
is considered filled if any of the following conditions are met:
null
,0
,boolean
,Countable
object and contains items,empty
evaluates to false
The signature of the filled
function is:
1function filled(2 $value3);
The following example demonstrates the basic usage of the filled
method and is the opposite of the example provided in the blank
section:
1// Set a value to null. 2$testValue = null; 3 4if (filled($testValue)) { 5 // Perform some action when the 6 // supplied value is not 'blank'. 7} else { 8 // Perform a different action when the 9 // supplied value is 'bank'.10}
∎
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.