0
我有兩種方法,我希望在第一種方法中調用另一種方法。他們在同一個控制器中。我想這樣,但我得到的錯誤:如何從Kohana 3中的同一控制器的另一個方法調用一個方法3
Call to undefined method
Controller_User::getUser()
我的控制器看起來像這樣:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_User extends Controller {
public function action_index(){
$id = $this->request->param('id');
$user = self::getUser($id);
}
public function action_getUser ($id){
//some code here
}
}
該方法被命名爲'action_getUser',而不僅僅是'getUser'。另外'$ this-> action_getUser($ id)'會起作用(如果你不想這樣做,請將方法聲明爲['static'](http://php.net/manual/language.oop5.static。 php)) – kero
謝謝,現在很好。 –