I have just extended my PHP coding standard guidelines with these rules about variable naming:

  • Remember this is PHP, not Microsoft Visual C++. There is actually little value in naming variables something like strFullTitle . Something like full_title is definitely enough and much easier to read!
  • As an exception to the previous rule, we’ll preferably prefix private or protected member variables of a class with an underscore as in _full_title. This serves as an easy reminder that the variable is not designed to be called in any other ways as in $this->_full_title
  • Class names should start with a capital, as in Book.
  • Variable names should be all lowercase, as in $title = 'A brand new day'; except when they are object references as in: $a_Book = &new Book( 'A brand new day' );
  • When naming object references, always end their name with the name of the class as in $a_Book or $another_Book instead of $Book_to_read for example. This allows to easily search & find all calls to a given method of a given class. You could for example easily search on this string: Book->get_title(".

Comments from long ago:

Comment from: Free Shopping

A very useful resource for PHP coding guidelines here http://www.evolt.org/article/PHP_coding_guidelines/18/60247/

cheers

2005-11-17 12-15