Skip to content

Instantly share code, notes, and snippets.

View IsaacVanName's full-sized avatar

Isaac Van Name IsaacVanName

View GitHub Profile
@IsaacVanName
IsaacVanName / PHP Method Chaining from Constructor
Created December 23, 2010 17:39
PHP Method Chaining from Constructor
/*
new MyClass->my_method() isn't possible. However, there are a couple of solutions, of which the best seems to be the most unlikely as well.
****
Note: Make sure you read/skim to the end, even if you figure out the first solution quickly
(which you should). The second solution has a bit of brief research to go along with it! :-)
****
At times, it can be useful to have a class that maintains state long enough to complete a
cycle, but doesn't get stored in memory. No extra baggage needed, right?