Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Exakat Blog:
5 usages of static keyword in PHP
Jun 20, 2018 @ 15:28:21

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.

tagged: static keyword example tutorial method property closure variable classname

Link: https://www.exakat.io/5-usages-of-static-keyword-in-php/

Stephan Hochdörfer:
Defining Phing Tasks in PSR-0 style
Jan 23, 2015 @ 16:42:49

In his latest post Stephan Hochdörfer shows you how to define Phing tasks according to the PSR-0 autoloading format. Phing is a PHP-based automation tool that uses an XML configuration to execute a series of tasks.

Before anybody complains: I know that "as of 2014-10-21 PSR-0 has been marked as deprecated. PSR-4 is now recommended as an alternative." - Anyway I still think this little gem makes sense to be shared because a lot of people are probably not aware of it. I recently found out by accident that it is possible pass a task name in PSR-0 style to the "taskdef" task. In the old days you had to use the Java-like dot-style notation like this and also define the classpath to make sure the class could be loaded correct! This is ok if the task resides in the same project. If the task is located in a dependent package loaded via Composer this can get ugly.

The post is quick but provides two very handy code examples, one showing the old "dot notation" version and the other showing how to make use of the autoloader. The trick is in the classname value and using the full namespace/class name rather than the dot notation.

tagged: phing build task psr0 classname path autoload

Link: http://blog.bitexpert.de/blog/defining-phing-tasks-in-psr-0-style/

Zend Developer Zone:
ACRONYM or MixedCasing in Zend Framework 2? You decide!
Jul 12, 2010 @ 18:54:57

On the Zend Developer Zone there's a new post from Matthew Weier O'Phinney asking a question of all of the Zend Framework users out there - which do you prefer - ACRONYM or MixedCasing for how acronyms are presented in class names.

As an example, many suggest that "Zend_PDF" is more semantically correct and easier to remember than "Zend_Pdf". On the other side of the coin, many developers feel that our MixedCasing or Titlecasing of acronyms is a simple, easily learned rule that makes typing easier. For ZF2, we started converting code to use each acronym's proper casing. However, we're not done yet, and there are good arguments on both sides of the debate.

They've set up a survey on the topic and encourage as many people as have opinions to go and cast their vote. The survey will close in about a week, so be sure and make your thoughts heard on the matter before then!

tagged: acronym mixedcase classname zendframework

Link:


Trending Topics: