php compare intgerts code example

Example 1: php if less than number

<?php
if ($a > $b)
  echo "a is bigger than b";
?>

Example 2: php ?? vs ?:

<?php
var_dump(null ?? '`null` is null'); // `null` is null
var_dump(null ?: '`null` is empty'); // null
var_dump(true ?? '`true` is null'); // true
var_dump(true ?: '`true` is empty'); // true
var_dump(false ?? '`false` is null'); // false
var_dump(false ?: '`false` is empty'); // `false` is empty"
var_dump('' ?? 'empty string is null'); // ""
var_dump('' ?: 'empty string is empty'); // "empty string is empty"
var_dump(empty(null) ?: '`null` is not empty'); // true

Tags:

Php Example