Last active
February 28, 2026 07:20
-
-
Save stemar/d80ba8f6a818c30bf2a4fec4261c7b27 to your computer and use it in GitHub Desktop.
Check if a value is blank but not zero.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Check if a value is blank but not zero. | |
| * When you need to accept these as valid, non-empty values: | |
| * - 0 (0 as an integer) | |
| * - 0.0 (0 as a float) | |
| * - "0" (0 as a string) | |
| */ | |
| function is_blank(mixed $value): bool { | |
| return empty($value) && @!is_numeric($value); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment