note 91904 deleted from language.operators.comparison by danbrown

From: Date: Wed, 01 Jul 2009 12:50:16 +0000
Subject: note 91904 deleted from language.operators.comparison by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157772@lists.php.net to get a copy of this message
Note Submitter: Alex Lance ---- Not a fan of the ternary operator. I prefer using 'and' or 'or', as they have a lower priority than the assignment operator '=' (unlike &&, ||) and can be used like: <?php // if $alice, then $bob gets the value of $alice $alice and $bob = $alice; // if not $alice, then $alice gets the value of the $default $alice or $alice = $default; // $str gets the value of $_GET[test], or if $_GET[test] is empty, then $str gets the value of $_POST[test] $str = $_GET["test"] or $str = $_POST["test"]; ?> If you read the code aloud left-to-right, the meaning is easily understood. "string gets the value of GET-test, or string gets the value of POST-test."

« previous php.notes (#157772) next »