CHAPTER 12 – PEAR STANDARDS – Methods

Methods are named with an initial lowercase letter and an uppercase letter at the start of every word or token after the first, just like Java. Acronyms and abbreviations that are normally written in all uppercase are kept in uppercase. Here are some examples: class Foo { function test() ... function anotherTest() ... function toHTML() ... } For private methods, you have two options. If you care about PHP 4 com- patibility, prefix the names of "private" methods with an underscore: class Foo { function _privateMethod() ... } Note that in PHP 5, this method is actually public. The leading under- score is just a naming convention. If PHP 4 compatibility is not an issue, use private function without the underscore prefix: class Foo { private function privateMethod() ... }

Post Comment
Login to post comments