Re: http response 200

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux