Reputation: 7785
Why do some people call their functions e.g. '__makethis()' and '_makethat()'?
Is this any special feature or is this just in fashion?
thx for your answers ;)
Upvotes: 8
Views: 4327
Reputation: 9400
Usually private members of a class are prefixed with a '_' sign. Check out the PEAR code convention.
Magic methods of a class are prefixed with __ . I suggest if you write a method that performs some magic, prefix it with __ .
Upvotes: 2
Reputation: 349
The double underscore can sometimes be magic functions used by the PHP classes.
The single underscore can be part of their own naming convention for functions. But usually it means that a function is private, back in PHP4 classes didn't support private (or protected) functions, so people fake a private function that way (tho the function is not private in reality).
Upvotes: 8