Aaron Saray

open source programmer,
web developer

entrepreneur, author
and musician

My Blog

contains PHP, Web and business/entrepreneurial related content. Please join in the conversation!

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!

This entry was posted in PHP and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>