Search code examples
laraveleloquentlaravel-8laravel-eloquent-resource

How can check variables is null or empty with one function in laravel 8?


I want to check if there is a function in laravel 8 like IsNullOrEmpty for C# to check for empty and null value using just one function.


Solution

  • you can use empty() PHP function. The empty() function checks whether a variable is empty or not.

    This function returns false if the variable exists and is not empty, otherwise it returns true.

    The following values evaluates to empty:

    1. 0
    2. 0.0
    3. "0"
    4. ""
    5. FALSE
    6. array()
    7. NULL