note 105577 added to language.expressions

From: Date: Mon, 29 Aug 2011 19:03:19 +0000
Subject: note 105577 added to language.expressions
Groups: php.notes 
Request: Send a blank email to php-notes+get-182814@lists.php.net to get a copy of this message
Simple trick to current need: I want to get a function result in a variable or another value if it is empty. Instead of a long if then else structure like: $x = myFunction($y); if (empty($x)) x$ = otherFunction($z) or a slow or dangerous execution duplication like: $x = (empty(myFunction($y)) ? otherFunction($z) : myFunction($y)); you can use the short and easy to read syntax: if (! $x = myFunction($y)) x$ = otherFunction($z); ---- Server IP: 216.235.13.26 Probable Submitter: 205.211.133.130 ---- Manual Page -- http://www.php.net/manual/en/language.expressions.php Edit -- https://master.php.net/note/edit/105577 Del: integrated -- https://master.php.net/note/delete/105577/integrated Del: useless -- https://master.php.net/note/delete/105577/useless Del: bad code -- https://master.php.net/note/delete/105577/bad+code Del: spam -- https://master.php.net/note/delete/105577/spam Del: non-english -- https://master.php.net/note/delete/105577/non-english Del: in docs -- https://master.php.net/note/delete/105577/in+docs Del: other reasons-- https://master.php.net/note/delete/105577 Reject -- https://master.php.net/note/reject/105577 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182814) next »