Home > Article > Backend Development > Match php regular matching function body
Copy the code The code is as follows:
$data = php_strip_whitespace('test.php'); //Remove comments, spaces, and newlines (excluding those in the string)
echo $data ;
$data = preg_match_all("
/
functions+ #Match function and the following space
[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]* #Match function name
(([^ )]*?))s+ #Match function parameters and capture them as subpatterns
{
(.*?)
}(?=(?:s*function|s*?$)) #Match curly brackets only if When followed by function or at the end of the string
/xi
", $data, $matches);
print_r($matches);
?>
The above introduces the matching PHP regular matching function body, including matching content. I hope it will be helpful to friends who are interested in PHP tutorials.