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 😉
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).
That’s a convention for naming private and protected methods.
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 __ .