How to get the code of the method? I'm trying something like this: :
//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';
*/
I don't know how to get the code with nested braces. Any ideas?