note 37585 added to control-structures.alternative-syntax

From: Date: Thu, 20 Nov 2003 10:11:48 +0000
Subject: note 37585 added to control-structures.alternative-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-60674@lists.php.net to get a copy of this message
My personal preference on alternating writing is like this: $query="select * from books"; sizeof($myparam) and $query.=" where title like '%$myparam%'"; Which means: if (sizeof($myparam)) $query.= ... You can even combine this with the ? structure. Like: $query="select * from books"; strlen($title) and $c1=" title like '%$title%'"; strlen($year) and $c2=" year=$year"; strlen($c1) and $q2=$c1; strlen($c2) and $q2.= (strlen($q2)) ? "and $c2" : $c2; strlen($q2) and $query.=" where $q2"; Well, how about this? Can it be done easier? :) I think is is called lazy Vs eager calc. ---- Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37585 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37585&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37585&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60674) next »