Home  >  Article  >  Backend Development  >  How to use php addcslashes function

How to use php addcslashes function

藏色散人
藏色散人Original
2019-01-31 09:52:022410browse

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)

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>";
?>

Output:

Welcome to php.cn!
Welco\me to php.cn!
Welcome to \ph\p.cn!

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!

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