Re: http response 200

From: Date: Fri, 20 Jun 2008 20:28:56 +0000
Subject: Re: http response 200
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-275737@lists.php.net to get a copy of this message
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

« previous php.general (#275737) next »