子→親に引数を渡したいのですが、
子っていうのがController_Templateを継承したコントローラーで、
親っていうのがController_Templateの事でしょうか?
オブジェクト指向的には、
という、protectedな変数を定義すると、親子間のみでアクセスできる変数を定義できます。
これにアクセスする場合は、$this修飾子をつけてアクセスします。
class Controller_Hoge extends Controller_Template
{
protected $hogehage;
public function action_hoge()
{
$this->hogehage = "abc"; ←Controller_Templateでも利用できます
}
}
こんな感じですね。
親の方に定義するんでしたね…
abstract class Controller_Template extends \Controller
{
/**
* @var string page template
*/
public $template = 'template';
// 親子で利用できる変数
protected $hogehage = "test";
}
class Controller_Hoge extends Controller_Template
{
public function action_hoge()
{
echo $this->hogehage;
}
}
こんな感じですね。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/04/17 00:56
退会済みユーザー
2015/04/17 01:35