Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How PHP uses ereg_replace () and eregi_replace ()

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how PHP uses ereg_replace () and eregi_replace (). I hope you will get something after reading this article. Let's discuss it together.

Ereg_replace () and eregi_replace ()

Function prototype: string ereg_replace (string $pattern, string $replacement, string $string)

String eregi_replace (string $pattern, string $replacement, string $string)

Ereg_replace () searches for the pattern string $pattern in $string and replaces the matching result with $replacement. When $pattern contains pattern units (or subpatterns), the position in $replacement that looks like "/ 1" or "$1" will in turn be replaced by what these subpatterns match. "/ 0" or "$0" refers to the contents of the entire matching string. It is important to note that the backslash is used as an escape character in double quotes, so you must use the form "/ / 0", "/ / 1".

Eregi_replace () and ereg_replace () have the same functionality, except that the former ignores case. Code 6.6 is an application example of this function, which demonstrates how to do a simple clean up of the program source code.

Code 6.6 Source Code cleanup

The code is as follows:

After reading this article, I believe you have some understanding of "how PHP uses ereg_replace () and eregi_replace ()". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report