Re: PHP Brain Teasers
| From: | Daniel Brown | Date: | Tue, 26 Jun 2007 18:39:54 +0000 |
| Subject: | Re: PHP Brain Teasers | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257806@lists.php.net to get a copy of this message | ||
On 6/26/07, Tijnema <tijnema@gmail.com> wrote:
On 6/26/07, Daniel Brown <parasane@gmail.com> wrote: 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) {No, I just made some stuff up. I thought it could be fun, and a decent exercise in coding. Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though.... that is what they say.... -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107whistle();} ?> .... 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): Yes, of course, call it simple... :P It took me 20 minutes to figure it out :S :P <? 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 Oh, and how do we make such things? Is there a manual about them? :P TIjnema -- Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info