PHP Brain Teasers

From: Date: Tue, 26 Jun 2007 17:44:14 +0000
Subject: PHP Brain Teasers
Groups: php.general 
Request: Send a blank email to php-general+get-257802@lists.php.net to get a copy of this message
What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done anywhere else yet, but I wouldn't be surprised if it has been. Let's put together some names, phrases, and other stuff expressed as PHP code and see who can come up with a real stumper. For example: <? while($u_work) {
       whistle();
} ?> .... would be "Whistle While You Work." Try to use some really common phrases that all of us around the world should recognize, but feel free to get really elaborate with the code. So here's the first one (it's simple): <? function at($level) {
       $level == 10 ? $ret = "winner" : '';
       $level == 15 ? $ret = "try" : '';
       $level == 20 ? $ret = "first" : '';
       $level == 25 ? $ret = "user" : '';
       $level == 30 ? $ret = "place" : '';
       $level == 35 ? $ret = "again" : '';
       $level == 40 ? $ret = "succeed" : '';
       $level == 45 ? $ret = "last" : '';
       $level == 50 ? $ret = "finish" : '';
       return $ret;
} if(at(20) != "succeed") {
       try {
               $e = "again";
               throw new Exception($e);
       } catch(Exception $e) {
               echo "Try ".$e->getMessage()."\n";
       }
} ?> -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107

« previous php.general (#257802) next »