note 91904 added to language.operators.comparison

From: Date: Wed, 01 Jul 2009 07:55:39 +0000
Subject: note 91904 added to language.operators.comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-157747@lists.php.net to get a copy of this message
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: // 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." ---- Server IP: 117.104.162.229 Probable Submitter: 114.76.148.74 (proxied: 114.76.148.74) ---- Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php Edit -- https://master.php.net/note/edit/91904 Del: integrated -- https://master.php.net/note/delete/91904/integrated Del: useless -- https://master.php.net/note/delete/91904/useless Del: bad code -- https://master.php.net/note/delete/91904/bad+code Del: spam -- https://master.php.net/note/delete/91904/spam Del: non-english -- https://master.php.net/note/delete/91904/non-english Del: in docs -- https://master.php.net/note/delete/91904/in+docs Del: other reasons-- https://master.php.net/note/delete/91904 Reject -- https://master.php.net/note/reject/91904 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157747) next »