Is PHP's __call() used when no __construct is present?

This post is more than 18 months old. Since technology changes to rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with the current release.

Simple enough question. Lets 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');

Ran the first time, the output was:

constructed with: hi

Ran without a constructor?

BLANK. __call is not called.

Now we can all sleep at night! whew!

PHP

Return to All Posts