Skip to content

Instantly share code, notes, and snippets.

@stemar
Last active February 28, 2026 07:20
Show Gist options
  • Select an option

  • Save stemar/d80ba8f6a818c30bf2a4fec4261c7b27 to your computer and use it in GitHub Desktop.

Select an option

Save stemar/d80ba8f6a818c30bf2a4fec4261c7b27 to your computer and use it in GitHub Desktop.
Check if a value is blank but not zero.
<?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