Detailed explanation of addcslashes() function in PHP

autoload
Release: 2023-03-09 14:14:01
Original
2197 people have browsed it

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   )
Copy after login
  • $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,&#39;n&#39;)."<br>"; 
echo addcslashes($str,&#39;h&#39;)."<br>"; 
?>
Copy after login
输出:
Welcome to php.cn!
Welcome to php.c\n!
Welcome to p\hp.cn!
Copy after login

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!

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