用php自帶函式去除html標記

2021-09-01 07:51:30 字數 669 閱讀 9492

strip_tags

去掉 html 及 php 的標記。

語法: string strip_tags(string str);

傳回值: 字串

函式種類: 資料處理

內容說明

本函式可去掉字串中包含的任何 html 及 php 的標記字串。若是字串的 html 及 php 標籤原來就有錯,例如少了大於的符號,則也會傳回錯誤。而本函式和 fgetss() 有著相同的功能。

htmlspecialchars

將特殊字元轉成 html 格式。

語法: string htmlspecialchars(string string);

傳回值: 字串

函式種類: 資料處理

& (和) 轉成 &

" (雙引號) 轉成 "

< (小於) 轉成 <

> (大於) 轉成 >

此函式只轉換上面的特殊字元,並不會全部轉換成 html 所定的 ascii 轉換。

使用範例

<?php   

$new  = htmlspecialchars( "test" , ent_quotes);  

echo

$new ;

?> 

用php自帶函式去除html標記

strip tags 去掉 html 及 php 的標記。語法 string strip tags string str 傳回值 字串 函式種類 資料處理 內容說明 本函式可去掉字串中包含的任何 html 及 php 的標記字串。若是字串的 html 及 php 標籤原來就有錯,例如少了大於的符號,...

php中自帶函式 json encode

php場景中,需要將陣列轉為json字串,就需要用到php自帶的json encode函式 但是當陣列中含有中文字串時,轉出來的結果卻是以下結果 1 tmparr array 4 name 長褲 5 color blue 6 size xl 7 title 中年 長褲 8 910 tmpjson j...

c語言 fgets函式 去除換行符 C語言指標小結

最近發現自己c語言基礎還是很薄弱,去廣圖借了本 c指標原理揭秘 基於底層實現機制 深入學下指標大家想必都在windows中使用過ping 127.0.0.1 t,其中這些引數怎麼來的呢?看下面 include include int main int argc,char ar 我們平時直接就int ...