您好,欢迎访问一九零五行业门户网

PHP的preg_replace函数的有关问题

php的preg_replace函数的问题
$string = april 15, 2003;
$pattern = /(/w+) (/d+), (/d+)/i;
$replacement = /${1}1,/$3;
print preg_replace($pattern, $replacement, $string);
/* output
======
april1,2003
*/
$replacement = /${1}1,/$3;
/${1}1,/$3这个是什么意思?
$patterns = array (/(19|20)(/d{2})-(/d{1,2})-(/d{1,2})/,
/^/s*{(/w+)}/s*=/);
$replace = array (//3///4///1//2, $//1 =);
print preg_replace ($patterns, $replace, {startdate} = 1999-5-27);

$replace = array (//3///4///1//2, $//1 =);这个也是什么意思?
------解决方案--------------------
双引号中 php 会试图将 $ 解释为变量的前导
字符串 ${1} 将引起变量未定义的错误
所以要转义掉,这样才会把 ${1} 交给 prea_replace 去处理
其它类似信息

推荐信息