PHP addcslashes() 函数

PHP addcslashes() 函数

PHP addcslashes() 函数用于在 C 风格中添加带有转义字符的引号字符串。它是大小写敏感的。

语法

string addcslashes ( string str , stringcharlist )
参数 描述 必需/可选
字符串 需要转义的字符串 必需
字符 需要转义的字符或范围 必需

示例1

<?php
str="Welcome to JavaTpoint";
echo "Your String : ".str;
echo "<br>"."By using 'addcslashes()' method your string: ".addcslashes($str,'T')."<br>";
?>

输出:

Your String : Welcome to JavaTpoint
By using 'addcslashes()' method your string: Welcome to Java\Tpoint

示例2

<?php
str="Welcome to JavaTpoint";
echo "Your String : ".str;
echo "<br>"."By using 'addcslashes()' method your string: ".addcslashes($str,'a')."<br>";
?>

输出:

Your String : Welcome to JavaTpoint
By using 'addcslashes()' method your string: Welcome to J\av\aTpoint

示例3

<?php
str ="Welcome to JavaTpoint"."<br>";
echo "str";
echo addcslashes($str,'A..Z')."<br>";
?>

输出:

Welcome to JavaTpoint
\Welcome to \Java\Tpoint

示例4

<?php
str ="Welcome to JavaTpoint"."<br>";
echo "str";
echo addcslashes($str,'a..z')."<br>";
?>

输出:

Welcome to JavaTpint
W\e\l\c\o\m\e \t\o J\a\v\aT\p\o\i\n\t<\b\r>

示例5

<?php
str ="Welcome to JavaTpoint";
echo "Your string value is: ".str."<br>";
echo "By using addcslashes() Function your value is : ".addcslashes($str,'a..m');
?>

输出:

Your string value is: Welcome to JavaTpoint
By using addcslashes() Function your value is : W\e\l\co\m\e to J\av\aTp\oint

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程