corillo181 Posted December 23, 2007 Share Posted December 23, 2007 i have a class example <?php class student{ public $id; function __construct($id){ $this->id = $id; } } ?> and a class that extends it example <?php class name extends student{ } ?> my questions if i want to add a __construct to the class name how would i do that? when i do it it takes away the id from the parent and i need to be able to pass a id to it also. Quote Link to comment Share on other sites More sharing options...
trq Posted December 23, 2007 Share Posted December 23, 2007 <?php <?php class name extends student{ function __construct() { parent::__construct(); /// more stuff here. } } ?> Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 24, 2007 Author Share Posted December 24, 2007 parent::__construct() no parameters? Quote Link to comment Share on other sites More sharing options...
trq Posted December 24, 2007 Share Posted December 24, 2007 Sorry, didn't look too closely to your code. <?php <?php class name extends student{ function __construct($id) { parent::__construct($id); /// more stuff here. } } ?> Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 24, 2007 Author Share Posted December 24, 2007 alright thanks.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.