stripcslashes() 是 PHP 中的內置函數,用於刪除為轉義字符串中某些字符而添加的反斜杠。它反轉了 addslashes() 函數的效果。它識別 C-language 字符,例如 \n、\r …、八進製和十六進製表示形式。
用法
stripcslashes(string $string): string;
參數
該函數僅接受單個參數,如下所述:
- $字符串:要從中刪除反斜杠的輸入字符串。
返回值
stripcslashes() 函數從未轉義的字符串返回轉義的字符串。
程序1:下麵的程序演示了stripcslashes()函數。
PHP
<?php
$escaped_string =
"This is an example with \\'escaped\\' characters.";
$original_string = stripcslashes($escaped_string);
echo "Escaped String: $escaped_string<br>.\n";
echo "Original String: $original_string";
?>
輸出
Escaped String: This is an example with \'escaped\' characters.<br>. Original String: This is an example with 'escaped' characters.
程序2:下麵是另一個程序,演示了stripcslashes()函數。
PHP
<?php
$escaped_string =
"This is an example with \\'escaped\\' characters.";
$original_string = stripcslashes($escaped_string);
if ($escaped_string === $original_string) {
echo
"String was not escaped: $original_string";
} else {
echo
"String was escaped and then unescaped: $original_string";
}
?>
輸出
String was escaped and then unescaped: This is an example with 'escaped' characters.
參考: https://www.php.net/manual/en/function.stripcslashes.php
相關用法
- PHP stripcslashes()用法及代碼示例
- PHP stripos()用法及代碼示例
- PHP strip_tags()用法及代碼示例
- PHP stripslashes()用法及代碼示例
- PHP string Implode()用法及代碼示例
- PHP string crypt()用法及代碼示例
- PHP string join()用法及代碼示例
- PHP string lcfirst()用法及代碼示例
- PHP string levenshtein()用法及代碼示例
- PHP string ltrim()用法及代碼示例
- PHP string md5()用法及代碼示例
- PHP string md5_file()用法及代碼示例
- PHP string money_format()用法及代碼示例
- PHP string number_format()用法及代碼示例
- PHP string ord()用法及代碼示例
- PHP string parse_str()用法及代碼示例
- PHP string printf()用法及代碼示例
- PHP string quotemeta()用法及代碼示例
- PHP string rtrim()用法及代碼示例
- PHP string setlocale()用法及代碼示例
- PHP string sha1()用法及代碼示例
- PHP string sha1_file()用法及代碼示例
- PHP string similar_text()用法及代碼示例
- PHP string str_ireplace()用法及代碼示例
- PHP string str_pad()用法及代碼示例
注:本文由純淨天空篩選整理自neeraj3304大神的英文原創作品 PHP stripcslashes() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。