Christian Koch
Christian Koch

Reputation: 701

Lowercase methods with the same name as the class recognized as constructor

Using PHP 5.5. I'm having the following problem:

class Foo {
    function __construct() {
    }

    function foo($bar) {
    }
}

There is a valid constructor and my method foo() is lowercase. If i create an object with

$f = new Foo();

I get a warning like

Warning: Missing argument 1 for Foo::foo()

So PHP interprets the method foo() as a second constructor. Is there a PHP setting to stop this behavior?

Thank you

Chris

Upvotes: 2

Views: 85

Answers (1)

Colin vH
Colin vH

Reputation: 537

User-defined PHP functions are case-insensitive. :-(

Upvotes: 2

Related Questions