Is PHP's __call() Used When No __construct is Present?

Jan 11, 2009 php
This post is more than 18 months old. Since technology changes too 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. 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');

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!

Go to All Posts