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 } } ?> Link to comment https://forums.phpfreaks.com/topic/277577-call-to-undefined-method-x/ Share on other sites More sharing options...
Barand Posted May 3, 2013 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(); Link to comment https://forums.phpfreaks.com/topic/277577-call-to-undefined-method-x/#findComment-1427950 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. Link to comment https://forums.phpfreaks.com/topic/277577-call-to-undefined-method-x/#findComment-1427981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.