On the Exakat blog there's a new post sharing five uses of the "static" keyword in PHP applications. This includes the less common static closures and static class names.
Static is a PHP keyword with many usages. It is almost universally used, though there are many variations of it. Let’s review all the five of them :
- static method
- static property
- static closure
- static variable
- static as a classname
The post goes through each of the items in the list giving a brief explanation of how it's used and a code example showing it in action. The post finishes with some tips on evaluating your own code for the use of "static" and tips for each to make your code easier to wrangle and maintain in the future.