You can take advantage of the fact that the or
operator has lower precedence than =
to do this:
$page = (int) @$_GET['page']
or $page = 1;
If the value of the first assignment evaluates to true
, the second assignment is ignored. Another example:
$record = get_record($id)
or throw new Exception("...");