Home >Backend Development >PHP Problem >Detailed explanation of addcslashes() function in PHP
The previous article told you about "How to understand foreach traversing a two-dimensional array in php". This article mainly talks about php
The addcslashes()
function in. In the actual use of
php
, we may need to escape some characters in the string. At this time, we need to use the php
Built-in function addcslashes()
function, this article will take you to take a look.
addcslashes ( string $str , string $charlist )
$str: Characters to be escaped
$charlist: Characters or character range to be escaped.
Return value: escaped characters.
Code example:
<?php $str = "Welcome to php.cn!"; echo $str."<br>"; echo addcslashes($str,'n')."<br>"; echo addcslashes($str,'h')."<br>"; ?>
输出: Welcome to php.cn! Welcome to php.c\n! Welcome to p\hp.cn!
Recommended: 《2021 PHP interview questions summary (collection) 》《php video tutorial》
The above is the detailed content of Detailed explanation of addcslashes() function in PHP. For more information, please follow other related articles on the PHP Chinese website!