namespaces - Namespacing and including files in PHP -
i'm using namespaces construction files in project. have controller-class lives in php-file displays content user. in php-file file included. somehow constructed controller in 'parent'-php-file not available in included php-file. works fine when not using namespaces, how can fixed?
sample
# app\controllers\usercontroller.php namespace app\controllers class usercontroller { public function dosomething() { echo 'hello..'; } }
# parent.php utilize app\controllers controllers; $usercontroller = new controllers\usercontroller(); $usercontroller->dosomething(); // echo's 'hello..' include 'child.php';
# child.php $usercontroller->dosomething(); // phone call fellow member function dosomething on non-object
php namespaces include
No comments:
Post a Comment