Is it possible to turn off that method with the same name as class name is constructor? In PHP.
Here is an example...
class Foo {
function foo() { // This would be the constructor, but I don't want to... ='(
echo 'I was here!';
}
}
$foo = new Foo;
PHP v5.3.2 on Ubuntu开发者_StackOverflow社区.
Yes it is possible. According to the __construct
Documentation, it will not resolve that type of constructor for namespaced classes as of 5.3.2 (your version). So as long as your class is namespaced, it won't behave that way.
namespace My;
class Foo {
function foo() {
echo 'I was here!';
}
}
$foo = new Foo; // won't echo
精彩评论