Re: control structure question
| From: | Martin Clifford | Date: | Tue, 23 Jul 2002 14:06:42 +0000 |
| Subject: | Re: control structure question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-109083@lists.php.net to get a copy of this message | ||
For steps and sequences, I always use switches. Most commonly associated with the
"action" variable, it would look like this:
switch($action) {
default:
// what to show if no variable exists, or is set to a value
// that is not acceptable below
break;
case "add_file":
// what to do in the even that a file needs to be added
// to the database.
break;
case "remove_file":
// what to do in the even that a file need sto be removed
// from the database.
break;
}
Basically, whatever the value of $action, that is what section of code will execute. Hope that
helps!
Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/
>>> "Javier Montserat" <codareef@hotmail.com> 07/23/02 10:03AM >>>
is there a more programmatically elegant way of saying...
$isError = "";
function main() {
doStep1();
if (!$isError) {
doStep2();
}
if (!$isError) {
doStep3();
}
// etc. etc.
}
function doStep1() {
if ($something) {
$isError = 1;
}
}
function doStep2() {
if ($something) {
$isError = 1;
}
}
_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php