Drezard Posted January 23, 2008 Share Posted January 23, 2008 Okay so, I have something along the lines of this: fileA.php: <?php class A { function p() { echo 'Home'; } } ?> fileB.php: <?php include('fileA.php'); class B { function S() { $A->p(); } } ?> Okay, so thats the basic theory behind my code. But, its alot more complex in the functions. But, I want to call a function from Class A, in Class B. How would I declare Class A, so it could be used in Class B? Like a: public $A = new A; But, that doesn't work. Daniel Link to comment https://forums.phpfreaks.com/topic/87368-class-inside-a-class/ Share on other sites More sharing options...
rajivgonsalves Posted January 23, 2008 Share Posted January 23, 2008 you can use the RSO use the following class B { function S() { A:(); } } but what exactly are you trying to achieve why not just extend the class ? Link to comment https://forums.phpfreaks.com/topic/87368-class-inside-a-class/#findComment-446903 Share on other sites More sharing options...
trq Posted January 23, 2008 Share Posted January 23, 2008 <?php include('fileA.php'); class B { function S() { $A = new A; $A->p(); } } ?> Link to comment https://forums.phpfreaks.com/topic/87368-class-inside-a-class/#findComment-446947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.