Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 516 Bytes

File metadata and controls

26 lines (20 loc) · 516 Bytes

value

Returns the default value of the given value or Closure if they are null.

value($value, $default = null):mixed

  • (mixed) $value - a value or a Closure to check.
  • (mixed) $default - default value.

Pass a variable

$foo = 'bar';
$someVar = null;

value($foo, 'default value');  // Output: 'bar'.
value($someVar, 'default value');  // Output: 'default value'.

Pass a Closure

$func = function() {
// some calculation
return $result;
};

value($func, 'default value');