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 Quote 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 ? Quote 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(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87368-class-inside-a-class/#findComment-446947 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.