0

Hi guys,

I've made a class with a lot of functions, and for the 99% of the time i need the __construct functi.
How can i call the class without the __construct ?

class Test
{
    public function __construct()
    {
        echo "bla";
    }
}

$test = new Test();

What I want is when I call the new $test->blabla($test); the construct should not be invoked.

Edited by Szabi Zsoldos

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Szabi Zsoldos
1

__construct is the function that gets called when an object instance of the class is created. Even if you remove it, it will be called, so make sure you do not put any output in it. The only way around it is creating a static class.

0

That was my solution as well, created a static class after all.
Tought that I can skip the __construct :)

0

there is a php function called reflection class as shown here, but never tried it.

Tried this class, it works but still the __construct is passing trough :)
As pritaeas said, the simplest workaround is to build a separate static class :)

Edited by Szabi Zsoldos

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.