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

9 points by ecaron ↗ HN
I'm redecorating the office, and came across the challenge of needing 8 lines of PHP to spraypaint onto the wall at LinkUp.

The problem: I can't think of any code that's cool enough to display in 12" lettering for an extended period of time.

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?

7 comments

[ 0.24 ms ] story [ 25.3 ms ] thread
http://www.reddit.com/r/programming/comments/dst56/today_i_l...

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?

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();
  }
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.

I'd just go with "T_PAAMAYIM_NEKUDOTAYIM", personally.