Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
3 of 6
added more examples
Michał Tatarynowicz

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. This can be also useful for validating user input:

valid::email($email) 
  or $errors['email'] = "Please provide a valid e-mail address."
Pies