0

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.

Jon
  • 57
  • 3
  • 11

1 Answers1

2

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
  • But when you use eloquent get() function, empty() will not work. empty() returns true for collection and laravel eloquent get() return collection of objects. In this scenario you will have to use collection's isEmpty() or isNotEmpty() functions. – Masood Khan Nov 18 '20 at 15:06