Advanced PHP Problems -- For Fun

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
eduardodbarrete
Forum Newbie
Posts: 2
Joined: Fri Sep 26, 2008 10:37 am

Advanced PHP Problems -- For Fun

Post 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.
PolishHurricane
Forum Newbie
Posts: 4
Joined: Wed Oct 01, 2008 6:23 pm

Re: Advanced PHP Problems -- For Fun

Post 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.
Post Reply