PHP Regular matching function body _php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
$data = Php_strip_whitespace (' test.php '); Remove comments, spaces, line breaks (not including in the string)
Echo $data;
$data = Preg_match_all ("
/
function\s+ #匹配function和后面的空格
[A-za-z_\x7f-\xff] [A-za-z0-9_\x7f-\xff]* #匹配函数名
\(([^)]*?) \) \s+ #匹配函数参数 and captured as a sub-mode
\{
(.*?)
\}(?=(?:\ s*function|\s*?$)) #匹配大括号, only when the function is immediately behind or at the end of the string
/xi
", $data, $matches);

Print_r ($matches);
?>

http://www.bkjia.com/PHPjc/320554.html www.bkjia.com true http://www.bkjia.com/PHPjc/320554.html techarticle Copy the code as follows:? php $data = Php_strip_whitespace (' test.php ');//Remove comments, spaces, newline (excluding string) echo $data; $data = Preg_match_all (" /func ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.