No Warning For Unused Variables

<?php

  $a;
  // crii crii

  3 || $b;
  // ...

  echo $c;
  // Warning: Undefined variable $c

?>

PHP variable optimisation in action: the undefined variables are only reported when they are used.

The first is omitted : there are no operations.

The second is skipped : no need to execute the second term of the or.

The third is reporting a warning.

Of course, an assignation is not reported with an undefined variable, as it will be set. Although, may be reusage of a variable could be reported.

See Also

PHP Features

Last updated: 14 July 2026