メソッドのコードを取得するには? 私はこのようなことをしようとしています::
//SiteController.php
class SiteController{
public function actionIndex(){
//bla bla..
}
public function actionCustomMethod(){
if(1){
echo '1';
} else {
echo '2';
}
}
}
//i need take code of "function actionCustomMethod(){ ... }"
preg_match('/function actionCustomMethod[^}]+/i', file_get_contents('SiteController.php'), $out);
//but the preg_match returns
/*
public function actionCustomMethod(){
if(1){
echo '1';
*/
ネストされた中かっこでコードを取得する方法がわかりません。何か案は?