How PHP uses ereg_replace () and eregi_replace ()
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!