Skip to content

Comment on Underscore.php

Comments

If anyone else was surprised to see anonymous functions in PHP... apparently this is a new feature as of PHP 5.3.0 (released June last year).

Also be aware that anonymous functions do not close over variables unless you specify so: http://php.net/manual/en/functions.anonymous.php

And they can not close over $this, which is annoying.

It seems that it's fixed in PHP5.4; $this is the object in which you defined the closure by default, and you can re-bind it to any other object.

PHP 5.3.0 was released in June of 2009, not 2010.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.