相当简单;我似乎找不到有关PHP的preg_replace()
是否支持命名反向引用的明确信息:
// should match, replace, and output: user/profile/foo
$string = 'user/foo';
echo preg_replace('#^user/(?P<id>[^/]+)$#Di', 'user/profile/(?P=id)', $string);
这只是一个简单的例子,但我想知道这个语法 (?P=name)
是不是不被支持。是语法问题还是不存在此功能?