Archive for the ‘php’ Category

PHP is Dead

PHP is dead. Probably.
Allow me to preface this with some context. I

July 8, 2010   Posted in: php, rants  No Comments

How to be an Awesome Open Source Developer

I’m a big fan of open source. Capitalism is awesome, but it inspires and encourages greed, so it’s nice to see somebody defying that system by working hard at something, and then giving it away for free.
Of course, you’re at the mercy of whatever kind of limping scrod they shove out their codehole, but hey, [...]

February 22, 2010   Posted in: php, windows  No Comments

Reddit in 61 minutes and 97 lines of PHP

I read this article, about a guy who made a Reddit clone in 10 minutes in Clojure. He was inspired by this guy, who made a Reddit clone in Lisp in 20 minutes and a hundred lines.
I’m so sick of Lisp hackers. Functional programming is pretty awesome, but every single Lisp/Erlang/Haskell/Clojure/Emacs guy thinks Lisp is [...]

February 3, 2010   Posted in: php, rants  15 Comments

string.Format() in PHP

.NET’s sprintf() equivalent has ordered parameters.

var s = string.Format("My name is {1}, {0}", "Tommy", "Montgomery");
//s = "My name is Montgomery, Tommy"

var s = string.Format("My name is {{{0}}}", "Tommy");
//s = "My name is {Tommy}"

I needed that. Here it is, PHPified:

function format($format) {
$args = func_get_args();
$format = array_shift($args);

preg_match_all(‘/(?=\{)\{(\d+)\}(?!\})/’, $format, $matches, PREG_OFFSET_CAPTURE);
$offset = 0;
foreach ($matches[1] as $data) {
$i = [...]

January 9, 2010   Posted in: c#, php  No Comments