Home  >  Article  >  Backend Development  >  Match php regular matching function body

Match php regular matching function body

WBOY
WBOYOriginal
2016-07-29 08:40:371294browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn