Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PetroGromovo's avatar

Is using of blank function perferable now on laravel 10 site ?

I found a blank function at https://laravel.com/docs/10.x/helpers#method-blank, which seems replacement of php methods !empty and set. Is using of blanc function preferable now inlaravel code?

The same question as for the rest laravel helper methods, many of them are replacement of php native functions?

What do you prefer ?

"laravel/framework": "^10.48.7",

Thanks in advance!

0 likes
2 replies
jlrdw's avatar

which seems replacement of php methods

The function is:

    function blank($value)
    {
        if (is_null($value)) {
            return true;
        }

        if (is_string($value)) {
            return trim($value) === '';
        }

        if (is_numeric($value) || is_bool($value)) {
            return false;
        }

        if ($value instanceof Countable) {
            return count($value) === 0;
        }

        return empty($value);
    }
}

Please or to participate in this conversation.