

Ask HN: What's the coolest PHP snippet you know? - ecaron

I'm redecorating the office, and came across the challenge of needing 8 lines of PHP to spraypaint onto the wall at LinkUp.<p>The problem: I can't think of any code that's cool enough to display in 12" lettering for an extended period of time.<p>What code would you put up? The heart of phpBB? Leaked source code from the early days of Facebook? The first sample code that Rasmus ever made public? A WTF answer from phpGolf?
======
cheald
I'd just go with "T_PAAMAYIM_NEKUDOTAYIM", personally.

------
nbpoole
[http://www.reddit.com/r/programming/comments/dst56/today_i_l...](http://www.reddit.com/r/programming/comments/dst56/today_i_learned_about_php_variable_variables/c12np38)

One of the code examples from here might be good if you're looking to scare
people :-P

Edit: I have a more serious suggestion. Why not pick 8 lines from your own
codebase?

~~~
ecaron
I have been playing with that, the problem is that everything is really just
cool within its context. We also try to follow the logic that good code must
be easy to understand, not the kind of magic code that works great but can't
be debugged. Put that code on the wall and it is, well, boring.

The sample I started with is kind of a magic-method interpretation of how our
system works:

    
    
      <?php
      $jobs = array();
      foreach (Companies::getAll AS $company) {
        array_push($jobs, $company->getJobs();
      }
      $results = Search::fromKeyword($jobs);
      foreach ($results AS $result) {
        $result->displayJob();
      }

------
sdrinf
print_r( json_decode( file_get_contents(
"[http://twitter.com/statuses/user_timeline/hntweets.json?coun...](http://twitter.com/statuses/user_timeline/hntweets.json?count=1)),true
));

Oneliner: prints out the latest HN frontpage story

------
gorog
I would include a pattern matching line:

$date = "2011-07-29";

$list($year, $month, $day) = explode("-", $date);

With whatever is cooler than a date, or with the company's creation date.

------
smokeyhobie
while(pcntl_fork()|1);

------
ryanto
exit;

