Yohanne Posted May 3, 2013 Share Posted May 3, 2013 Hi all, how to call a function where a function is decleared into different or other page? page1.php <?php class class_a { public function x(); { code methods here. } } ?> page2.php <?php require_once 'page1.php'; class class_b { public function __cinstruct() { $new_class_a = new class_a(); } public function y(); { : how to call x function? here } } ?> Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted May 3, 2013 Solution Share Posted May 3, 2013 First, remove the ; after function x() and function y() in the definitions require_once("page1.php"); class class_b { private $new_class_a; public function __construct($a) { $this->new_class_a = $a; } public function y() { $this->new_class_a->x(); } } $b = new class_b(new class_a()); $b->y(); Quote Link to comment Share on other sites More sharing options...
Yohanne Posted May 3, 2013 Author Share Posted May 3, 2013 Okay, i will try it in home. thanks for this informative triks. and i think it is work great. 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.