My Blog

contains PHP and other web related content. (Sometimes there are some off topic things - don't freak out!)

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

Simple enough question. Lets check out some test code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
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!

Tags:

Leave a Reply

  • twitter loader

Follow me on twitter: @aaronsaray

The views on this website are my own and do not reflect the opinions of my employer or clients.
Creative Commons License Home | Open Source | Book | Music | Art | Bio | Resume | Contact
My Baby