At 3:57 PM -0400 6/20/08, Daniel Brown wrote:
My preference here would be:
<?php
if ($status == "RETEMP02") {
echo "Mobile number is empty.";
} elseif ($status == "RETEMP03") {
echo "Message is empty.";
} elseif ($status == "RETEMP05") {
echo "Message Id is empty.";
} elseif ($status == "RETVAL03") {
echo "Invalid mobile number.";
} elseif ($status == "RETVAL04") {
echo "Mobile number not recognized.";
} elseif ($status == "RETVAL05") {
echo "Message is containing illegal character.";
} elseif ($status == "") {
echo "Message sending failed";
} else {
echo "Message has been sent successfully.";
}
?>
Arrggg!
switch ($status)
{
case 'RETEMP02':
echo "Mobile number is empty.";
break;
case 'RETEMP03':
echo "Message is empty.";
break;
case 'RETEMP05':
echo "Message Id is empty.";
break;
case 'RETVAL03':
echo "Invalid mobile number.";
break;
case 'RETVAL04':
echo "Mobile number not recognized.";
break;
case 'RETVAL05':
echo "Message is containing illegal character.";
break;
default:
echo "Message has been sent successfully.";
break;
}
For me, this is easier to read, edit, maintain, and understand. And,
the reason why I have never used elseif -- thank God the case
statement came before elseif's.
And don't think that I don't see all of you scurrying away checking
old programming manuals to prove me wrong, but I think you'll find
I'm right. :-)
In any event, elseif's are vexations to the sprit.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php