class ClassA {
// NOT a normal function.
// This is the constructor function, and it's called whenever you create a new instance
public function ClassA() {}
}
$obj = new ClassA(); // call constructor ClassA::ClassA()
$obj->ClassA(); // call function ClassA::ClassA()
class ClassB {
public function __construct() {}
}
$obj = new ClassB(); // call to constructor __construct()
$obj = $obj->ClassB(); // call to function __construct()
And to complicate things
class ClassC {
public function ClassC() {}
public function __construct() {};
}
$obj = new ClassC(); // call to constructor __construct();
$obj->__construct(); // call to function __construct();
$obj->ClassC(); // call to function ClassC();
Now, I actually don't know if PHP is never case sensitive for function names, or if that's on certain systems only, but I'd assume it's on all platforms. so
class SOMECLASS {
// Still a constructor function. Just confusing as hell.
// i.e don't call your class SendMail and the constructor sendMail.
// Not even if all other functions start with lower case letters.
// class sendMail and function sendMail OR class SendMail and function SendMail
public function someclass() {}
}
Finally, some more weird stuff
class ClassD {
public function ClassD() { echo 'ClassD<br/>'; return 'sometimes a string, sometimes not'; }
}
$obj = new ClassD(); // output: ClassD
// $obj is an instance of ClassD. The constructor ALWAYS returns a reference to a new instance.
$str = $obj->ClassD(); // output: ClassD
/* $str is the string 'sometimes a string, sometimes not', since the above was not
considered a constructor call. And the same holds if you'd make a call like $obj->__construct(). */
However, relying on this kind of behaviour is most certainly a highway to debug hell.
You could of course define both SendMail() and __construct() to ensure that SendMail::SendMail() never is a constructor call, but I advice against that as well.
Now that we've covered the basics, the only thing I can guess at without seeing the actual code is that the constructor contains a return $this which screws up your call to explicit call to SendMail::SendMail() (that is, not the actual constructor call)