PHP Conference Japan 2024

stripcslashes

(PHP 4, PHP 5, PHP 7, PHP 8)

stripcslashes反引用用 addcslashes() 函式引用的字串

說明

stripcslashes(字串 $string): 字串

返回移除反斜線的字串。可識別 C 語言風格的 \n\r ... 等,以及八進位和十六進位表示法。

參數

字串

要取消跳脫的字串。

回傳值

返回取消跳脫的字串。

範例

範例 #1 stripcslashes() 範例

<?php

var_dump
(stripcslashes('I\'d have a coffee.\nNot a problem.') === "I'd have a coffee.
Not a problem."
); // true
?>

另請參閱

新增註解

使用者提供的註解 1 則註解

rafayhingoro[at]hotmail[dot]com
7 年前
stripcslashes 不僅會略過 C 語言風格的跳脫序列 \a、\b、\f、\n、\r、\t 和 \v,還會將它們轉換為實際的意義。

所以
<?php
stripcslashes
('\n') == "\n"; //true;

$str = "we are escaping \r\n"; //we are escaping

?>
To Top