Page 1 of 1

Advanced PHP Problems -- For Fun

Posted: Fri Sep 26, 2008 10:45 am
by eduardodbarrete
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


1. What is a design Pattern (If you don’t know Wikipedia is probably a good place to start)

2. Given,

Code: Select all

$POINT = “foobar”;
        Function foobar($how_bar);
        {
          Echo  “not just foobar, $how_bar  foobar.”;
        }
How can you call the function foobar(“really”); without directly calling the function foobar. Hint (use $POINT );


3. Do you think the following is funny? If so why?

Code: Select all

<?
 
         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";
       }
      }
     ?>
(Taken from http://readlist.com/lists/lists.php.net ... 26553.html)


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Advanced PHP Problems -- For Fun

Posted: Wed Oct 01, 2008 6:47 pm
by PolishHurricane
1) The reason why nobody has answered this thread.
2) call_user_func()
3) If at first you don't succeed, Try again. But I really think it's funny because that is the most horrid use of the ternary operator I've ever seen.