Is PHP's __call() Used When No __construct is Present?
This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against the current release.
Simple enough question. Let’s check out some test code:
class TEST
{
public function __construct($arguments)
{
print "constructed with: {$arguments}";
}
public function __call($name, $arguments)
{
print "called {$name} with: {$arguments}";
}
}
new TEST('hi');php
Ran the first time, the output was:
constructed with: hioutput
Ran without a constructor?
BLANK. __call is not called.
Now we can all sleep at night! whew!