corillo181 Posted September 2, 2007 Share Posted September 2, 2007 so i got 2 classes class one{ //do stuff } and i got a second one class two{ //do more stuff } what would i do if i want class one to bne in class 2 class two{ $one = new one(); } ? } Link to comment https://forums.phpfreaks.com/topic/67616-solved-call-class-in-side-of-class/ Share on other sites More sharing options...
trq Posted September 2, 2007 Share Posted September 2, 2007 <?php include 'one.php'; class two { private $one; function __construct() { $this->one = new one(); } } ?> Link to comment https://forums.phpfreaks.com/topic/67616-solved-call-class-in-side-of-class/#findComment-339669 Share on other sites More sharing options...
corillo181 Posted September 2, 2007 Author Share Posted September 2, 2007 so if i have a method i would call on it by $this->one->method(); ? Link to comment https://forums.phpfreaks.com/topic/67616-solved-call-class-in-side-of-class/#findComment-339694 Share on other sites More sharing options...
Ken2k7 Posted September 2, 2007 Share Posted September 2, 2007 That's OOP. And $this refers to the current class to get the variable one and then tell it to create a new one object. Link to comment https://forums.phpfreaks.com/topic/67616-solved-call-class-in-side-of-class/#findComment-339695 Share on other sites More sharing options...
corillo181 Posted September 2, 2007 Author Share Posted September 2, 2007 i made it work it was just the way i posted i just wasn't using the right method name. Link to comment https://forums.phpfreaks.com/topic/67616-solved-call-class-in-side-of-class/#findComment-339699 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.