Home >Backend Development >PHP Tutorial > 为何不能对正则匹配的值进行大写转换呢

为何不能对正则匹配的值进行大写转换呢

WBOY
WBOYOriginal
2016-06-13 12:54:471019browse

为什么不能对正则匹配的值进行大写转换呢?

	function syntax_color_sql($string)<br />
	{<br />
		$pattern='#select|left join|having|union|from|right join|limit|where|order by|for lock#sUi';<br />
		return preg_replace($pattern, '<font color="#ffcc00">'.strtoupper('$0').'</font>', $string);<br />
	}


------解决方案--------------------
本帖最后由 xuzuning 于 2013-01-25 12:38:54 编辑     $pattern='#select
------解决方案--------------------
left join
------解决方案--------------------
having
------解决方案--------------------
union
------解决方案--------------------
from
------解决方案--------------------
right join
------解决方案--------------------
limit
------解决方案--------------------
where
------解决方案--------------------
order by
------解决方案--------------------
for lock#sUie';
    return preg_replace($pattern, '"".strtoupper("$0").""', $string);
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