PHP method chaining or fluent interface?
I am using PHP 5 and I’ve heard of a new featured in the object-oriented approach, called ‘method chaining’. What is it exactly? How do I implement it?
I am using PHP 5 and I’ve heard of a new featured in the object-oriented approach, called ‘method chaining’. What is it exactly? How do I implement it?
I would like to know whether there’s a way to chain methods on a newly created object in PHP?
Is it possible to chain static methods together using a static class? Say I wanted to do something like this:
jQuery lets me chain methods. I also remember seeing the same in PHP so I wrote this: class cat { function meow() { echo "meow!"; } function purr() { echo "purr!"; } } $kitty = new cat; $kitty->meow()->purr(); I cannot get the chain to work. It generates a fatal error right after the meow. Answers: … Read more
I found this method chaining in python, but even with it I couldn’t understand method chaining in Python.