RE: PHP Brain Teasers

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

 



>     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";
>         }
> }
> ?>

The correct answer is:

"Parse error: parse error, unexpected '{' in /var/www/html/m.php on line 17"

Oh well, you know what they say:  "If at first you don't succeed..."

JM

-- 
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