PLZ: A handy PHP library for lazy programmers
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • amekusa
    • plz
  • PHP

Classes

  • alt
  • arr
  • constant
  • dom
  • fn
  • num
  • obj
  • op
  • path
  • str
  • sys
  • T
  • type
  • xml

Exceptions

  • ErrorException

Class alt

Fail-safe utilities

To get started, place the following line around top of your code.

use amekusa\plz\alt;
Abstract
Namespace: amekusa\plz
Located at alt.php

Methods summary

public static mixed
# null( mixed $X, mixed $Alt )

If $X is null, returns $Alt. Otherwise returns $X

If $X is null, returns $Alt. Otherwise returns $X

Parameters

$X
A variable to check
$Alt
A fail-safe value

Returns

mixed
$X or $Alt

Example

Demonstration

$var1 = 'Not Null';
$var2 = null;
var_dump( alt::null($var1, 'Null') );
var_dump( alt::null($var2, 'Null') );
string(8) "Not Null"
string(4) "Null"

public static mixed
# false( mixed $X, mixed $Alt )

If $X is falsy, returns $Alt. Otherwise returns $X

If $X is falsy, returns $Alt. Otherwise returns $X

Parameters

$X
A variable to check
$Alt
A fail-safe value

Returns

mixed
$X or $Alt

Example

Demonstration

$var1 = 'Truthy';
$var2 = '';
var_dump( alt::false($var1, 'Falsy') );
var_dump( alt::false($var2, 'Falsy') );
string(6) "Truthy"
string(5) "Falsy"

PLZ: A handy PHP library for lazy programmers API documentation generated by ApiGen