Tôi đã tạo 2 bộ điều khiển trong ứng dụng Yii: FirstController.php và SecondController.php trong đường dẫn bộ điều khiển mặc định.Chức năng gọi trong bộ điều khiển khác trong Yii
FirstController.php:
<?php
class FirstController extends Controller {
public static function returnFunc() { return 'OK'; }
}
SecondController.php:
<?php
class SecondController extends Controller {
public function exampleFunc() {
$var = First::returnFunc();
}
}
Khi tôi cố gắng thực hiện exampleFunc()
trong SecondController, Yii ném lỗi:
YiiBase::include(FirstController.php) [<a href='function.YiiBase-include'>function.YiiBase-include</a>]: failed to open stream: No such file or directory
Calling FirstController::returnFunc()
tương tự không làm việc.
Tôi là người mới làm quen trong khuôn khổ OOP và Yii. Có chuyện gì vậy?
http://www.yiiframework.com/forum/index.php/topic/6471-call-another-controllers-action/#entry200141 –