As a follow on to my short post about namespaces and functions from
a year ago I thought it would be worth covering importing a specific function and aliasing
functions via namespace operators too. This has been possible since PHP 5.6, but there is
a nice addition in PHP 7 I’ll cover towards the end.
In the previous article I demonstrated how you can namespace functions and use them, but
as a refresher; you can enclose functions within a namespace just like a class.
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...
In parts 1 and 2 of this series, we looked at PHP namespace basics, the use operator, and name resolution. In this final article we discuss some of the more advanced namespace options. The __NAMESPACE__ Constant __NAMESPACE__ is a P...
In part 1, we discussed why PHP namespaces are useful and the namespace keyword. In this article, we examine the use command and the way PHP resolves namespace names. For the purposes of this example, we will define two almost ident...