Using numbers in PHP function names

May 18, 2006

In PHP, function names have to start with either an underscore or some alpha-numeric character. However, most developers choose just the underscore (especially in PHP5 applications) and an alphabet character.


There is a problem with using procedural code in PHP. If you have hundreds of functions then you are going to run into naming problems after a while. In PHP function names not protected by OOP classes have to have unique names. This is no problem if you are not using a hook system like that of WordPress or Drupal. These CMS are coded using the underscore character as a designation for a hook system. This “hook_action” is an example.

Well as the project grows and becomes more popular then you start running out of humanly understandble words and letters to use. That or the names become too long to be remembered during normal development. So why don’t developers use numbers in the name of their functions?

Leave a Reply