PHP 8.5.0 Beta 1 available for testing

Voting

: seven plus one?
(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