I use camel case which has the first letter of all variable names, functions, etc lowercased. But the class names are capitalized. Should I use:
class Foo
{
function foo()
{
}
}
or :
class Foo
{
function Foo()
{
}
}
Which is a better convention? I’m confused.
Named constructors are PHP 4 convention. And yes, when you do it that way you should match the case of the class.
But PHP 4 is old news these days. PHP 5 has been the de-facto version for several years now. And PHP 5 uses a constant constructor name, __construct. It’s always this, regardless of the class’ name.