略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: 注释

2024-05-07

注释

字符序列(?#标记开始一个注释直到遇到一个右括号。不允许嵌套括号。 注释中的字符不会作为模式的一部分参与匹配。

如果设置了 PCRE_EXTENDED 选项, 一个字符类外部的未转义的 # 字符就代表本行剩余部分为注释。

add a noteadd a note

User Contributed Notes 1 note

up
-2
asamaru at asamaru dot net
5 years ago
<?php
$string
= 'test';
echo
preg_match('/te(?# comments)st/', $string) . "\n";
echo
preg_match('/te#~~~~
st/'
, $string) . "\n";
echo
preg_match('/te#~~~~
st/x'
, $string) . "\n";

// result
// 1
// 0
// 1

官方地址:https://www.php.net/manual/en/regexp.reference.comments.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3