Home >Backend Development >PHP Tutorial >PHP regular matching function body_PHP tutorial

PHP regular matching function body_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:44:20934browse

Copy code The code is as follows:

$data = php_strip_whitespace('test.php'); // Remove comments, spaces, and newlines (excluding those in strings)
echo $data;
$data = preg_match_all("
/
functions+ #Match function and following spaces
[a -zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]* #Match function name
(([^)]*?))s+ #Match function parameters and capture as sub-pattern
{
(.*?)
}(?=(?:s*function|s*?$)) #Match braces, only when followed by function or at the end of the string
/xi
", $data, $matches);

print_r($matches);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320554.htmlTechArticleCopy the code as follows: ?php $data = php_strip_whitespace('test.php'); //Remove the comments, Space, newline (not included in string) echo $data; $data = preg_match_all(" / func...
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