Home >Backend Development >PHP Problem >How to replace asterisks in a string in php

How to replace asterisks in a string in php

藏色散人
藏色散人Original
2021-11-25 09:26:243103browse

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.

How to replace asterisks in a string in php

#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.

How to replace asterisks in a string in php

In the test.php file, use the header() method to set the encoding format of the page to utf-8.

How to replace asterisks in a string in php

In the test.php file, create a string variable for testing.

How to replace asterisks in a string in php

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.

How to replace asterisks in a string in php

In the test.php file, use echo to output the replaced string.

How to replace asterisks in a string in php

Open the test.php file in the browser to view the results.

How to replace asterisks in a string in php

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!

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