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. Link to comment https://forums.phpfreaks.com/topic/82981-solved-class-extends/ 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. } } ?> Link to comment https://forums.phpfreaks.com/topic/82981-solved-class-extends/#findComment-422040 Share on other sites More sharing options...
corillo181 Posted December 24, 2007 Author Share Posted December 24, 2007 parent::__construct() no parameters? Link to comment https://forums.phpfreaks.com/topic/82981-solved-class-extends/#findComment-422048 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. } } ?> Link to comment https://forums.phpfreaks.com/topic/82981-solved-class-extends/#findComment-422049 Share on other sites More sharing options...
corillo181 Posted December 24, 2007 Author Share Posted December 24, 2007 alright thanks.. Link to comment https://forums.phpfreaks.com/topic/82981-solved-class-extends/#findComment-422065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.