Functional: page 1
A little known feature of PHP’s static keyword is that it allows for memoization or function caching. This is a process whereby a functions heavy lifting can be cached so that subsequent calls are faster. It is possible to store any value in a memoized way such as arrays or even objects. This is done without any external side effects - that is to say that the code calling the function will require no changes to support memoization. Read more ⇒
It is possible to treat a class instance as a function in PHP. Quite often this is referred to as a functor even though it should really be known as a function object. This is because functions actually serve a different role in languages that support their use. The convenience of having a reusable function that can be overloaded and carry a context is something to weigh up against using functions or closures. Read more ⇒
Functional Programming in PHP - The book
After working hard on the guide to Functional Programming in PHP I am pleased to announce that it has been published by php[architect]! The book is offcially now available and you can purchase your very own copy! If you’re a programmer who wants less bugs and easier testing then this is the functional introduction for you. Throughout the chapters I gently lead you through the various functional constructs available in and with PHP. Read more ⇒
Unicode shortcut in Netbeans for React/Curry
In some of my code I use a PHP library called React/Curry and to save typing it uses a unicode ellipsis (…) for a method name. Yes, that is right unicode method names can be legal in PHP! <?php $firstChar = Curry\bind('substr', Curry\…(), 0, 1); See I told you so! Well that is great, but how do you type a unicode character into a Netbeans document? To save having to constantly copy and paste the … character from a symbols list I have setup a very simple macro in Netbeans to print the character for me. Read more ⇒