Home > Backend Development > PHP Tutorial > How to use php addcslashes function

How to use php addcslashes function

藏色散人
Release: 2023-04-04 22:34:01
Original
2461 people have browsed it

php addcslashes function returns a string with a backslash added before the specified character. The syntax is addcslashes(string,characters). The parameter string is required and specifies the string to be escaped. Characters is required and specifies the characters or character range to be escaped.​

How to use php addcslashes function

#How to use the addcslashes function?

Function: Returns a string with a backslash added before the specified character

Syntax:

addcslashes(string,characters)
Copy after login

Parameters:

string Required, specified The string to escape.

characters Required, specifies the characters or character range to be escaped.

Description: Returns the escaped string.

php addcslashes() function usage example:

<?php
$str = "Welcome to php.cn!";
echo $str."<br>";
echo addcslashes($str,&#39;m&#39;)."<br>";
echo addcslashes($str,&#39;p&#39;)."<br>";
?>
Copy after login

Output:

Welcome to php.cn!
Welco\me to php.cn!
Welcome to \ph\p.cn!
Copy after login

This article is an introduction to the PHP addcslashes function. I hope it will help you if you need Friends help!

The above is the detailed content of How to use php addcslashes function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template