當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP stripcslashes()用法及代碼示例

stripcslashes() 是 PHP 的預定義函數。它用於刪除反斜杠並清理從數據庫或 HTML 表單中檢索到的數據。它返回一個去掉反斜杠的字符串。

當我們需要刪除反斜杠時,這個函數 stripcslashes() 很重要。

用法:

string stripcslashes ( string $str );
參數 描述 必需/可選
String 用於指定要檢查的字符串 required

例子1

<?php
  $str="Hello      PHP!";
  echo "Your String is:".$str;
  echo "<br>";
  echo "By using stripcslashes() Function".stripcslashes($str);
?>

輸出:

Hello PHP!

例子2

<?php
    $string="Hello, we areLearning PHP from javaTpoint.";
    echo "Before using 'stripcslashes()' Function:".$string;
    echo "<br>";
    echo "By using 'stripcslashes()' Function:".stripcslashes($string);
?>

輸出:

Before using 'stripcslashes()' Function:Hello, we areLearning PHP from javaTpoint.
By using 'stripcslashes()' Function:Hello, we areLearning PHP from javaTpoint.

參考:

http://php.net/manual/en/function.stripcslashes.php





相關用法


注:本文由純淨天空篩選整理自 PHP stripcslashes() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。