Ask HN: What's the coolest PHP snippet you know?
7 comments
I'd just go with "T_PAAMAYIM_NEKUDOTAYIM", personally.
exit;
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?
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:
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();
}print_r( json_decode( file_get_contents( "http://twitter.com/statuses/user_timeline/hntweets.json?coun...),true ));
Oneliner: prints out the latest HN frontpage story
Oneliner: prints out the latest HN frontpage story
while(pcntl_fork()|1);
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.
$date = "2011-07-29";
$list($year, $month, $day) = explode("-", $date);
With whatever is cooler than a date, or with the company's creation date.
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?