April 18, 2011

PHP, Extract function call name with regex

Question by hjke

$textvar = "Text(foo): " . func1("foo (bar)") . func2 ($some_arg);

What regex can I use to extract the above function names to verify
the existance of these functions?

Answer by Starx

How about this?

<? if(function_exists($function_name)) {
    //do something; 
}
?>

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!