Is there any way to initialize a class public variable at the time of object creation. But the case is that I have a child class and I dont want to over ride the parent constrctor. So is there any way out or any function that will be called at the time of object implicitly.

Thanks In advance

Recommended Answers

All 2 Replies

Is there any way to initialize a class public variable at the time of object creation. But the case is that I have a child class and I dont want to over ride the parent constrctor. So is there any way out or any function that will be called at the time of object implicitly.

Thanks In advance

I don't think there is anything else called by the PHP engine during instantiation of a class except for the constructor.

I think the question is why you don't want to override the parent. If the child class calls the parents constructor within its own constructor, then its just like not overriding the parent, except that you have are few more function calls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.