Home >Backend Development >PHP Problem >How to replace asterisks in a string in php
php method to replace asterisks in strings: 1. Create a new php file; 2. Create a string variable; 3. Use the str_replace function to replace "abc" in the string with asterisks; 4. Use echo to output the replaced string.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3.
How to replace asterisks in a string in php?
php replaces the specified characters in the string with asterisks
Create a new php file named test.php to explain how php converts characters Replace specified characters in the string with asterisks.
In the test.php file, use the header() method to set the encoding format of the page to utf-8.
In the test.php file, create a string variable for testing.
In the test.php file, use the str_replace function to replace "abc" in the string with an asterisk, and the result is stored in the $res variable.
In the test.php file, use echo to output the replaced string.
Open the test.php file in the browser to view the results.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to replace asterisks in a string in php. For more information, please follow other related articles on the PHP Chinese website!