intializing variable at time object creation

Reply

Join Date: Jul 2008
Posts: 2
Reputation: mahaguru is an unknown quantity at this point 
Solved Threads: 0
mahaguru mahaguru is offline Offline
Newbie Poster

intializing variable at time object creation

 
0
  #1
Jul 23rd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,429
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 231
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: intializing variable at time object creation

 
0
  #2
Jul 23rd, 2008
http://us3.php.net/manual/en/language.oop5.decon.php
Unless you have created a constructor that overrides the parent constructor it will use the inherited method
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,083
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: intializing variable at time object creation

 
0
  #3
Jul 24th, 2008
Originally Posted by mahaguru View Post
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.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 771 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC