dòng
匌3'; echo preg_replace('/[^<]*?/','',$a);Will"/> dòng
匌3'; echo preg_replace('/[^<]*?/','',$a);Will">

Home  >  Article  >  Backend Development  >  unknown error PHP regular Unknown Modifier error solution

unknown error PHP regular Unknown Modifier error solution

WBOY
WBOYOriginal
2016-07-29 08:41:591610browse

The following regular rules:

$a='2tóngdòng
3';
echo preg_replace('/[^<]*?/','',$a);

will prompt:

Warning: preg_replace(): Unknown modifier 'p' in E:phpLearntest.php on line 12

The reason is:

In the regular pattern, / is used as the delimiter, but the regular pattern also contains /, so this error will occur. PHP error The slash in the following is the ending delimiter.

Solution:

1. Add an escape character:

echo preg_replace('/[^<]*?/','',$a) ;

2. Change other delimiters: such as

echo preg_replace('{[^<]*?}','',$a) ;

The above introduces the unknown error PHP regular Unknown Modifier error solution, including the content of unknown error. I hope it will be helpful to friends who are interested in PHP tutorials.

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