ConFoo Montreal 2026: Call for Papers

Voting

: max(one, zero)?
(Example: nine)

The Note You're Voting On

phpnet at zc dot webhop dot net
12 years ago
This works similar to javascripts short-curcuit assignments and setting defaults. (e.g. var a = getParm() || 'a default';)

<?php

($a = $_GET['var']) || ($a = 'a default');

?>

$a gets assigned $_GET['var'] if there's anything in it or it will fallback to 'a default'
Parentheses are required, otherwise you'll end up with $a being a boolean.

<< Back to user notes page

To Top