• <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
  • <th id="l3qpx"><progress id="l3qpx"></progress></th>
      <th id="l3qpx"></th>
      <dd id="l3qpx"><font id="l3qpx"></font></dd>
      <th id="l3qpx"></th>
      0712-2888027 189-8648-0214
      微信公眾號(hào)

      孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號(hào)

      當(dāng)前位置:主頁(yè) > 技術(shù)支持 > PHP > php去除字符串中所有的HTML標(biāo)簽

      php去除字符串中所有的HTML標(biāo)簽

      時(shí)間:2016-04-01來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1330次
      php自帶的函數(shù)可以去除/刪除字符串中的HTML標(biāo)簽/代碼。

      strip_tags(string,allow):函數(shù)剝?nèi)?HTML、XML 以及 PHP 的標(biāo)簽。

      參數(shù):string,必填,規(guī)定要檢查的字符串;allow,選填,規(guī)定允許存在的標(biāo)簽,這些標(biāo)簽不會(huì)被刪除。

      $str = '郭碗瓢盆-<span style="color:#f00;">PHP</span>';
      $str1 = strip_tags($str);          // 刪除所有HTML標(biāo)簽
      $str2 = strip_tags($str,'<span>'); // 保留 <span>標(biāo)簽
      echo $str1; // 輸出 郭碗瓢盆-PHP
      echo $str2; // 樣式不一樣喔

      strip_tags — 從字符串中去除 HTML 和 PHP 標(biāo)記

      該函數(shù)嘗試返回給定的字符串 str 去除空字符、HTML 和 PHP 標(biāo)記后的結(jié)果。它使用與函數(shù) fgetss() 一樣的機(jī)制去除標(biāo)記。

      str輸入字符串。

      allowable_tags使用可選的第二個(gè)參數(shù)指定不被去除的字符列表。

      返回值:返回處理后的字符串。

      Example #1 strip_tags() 范例

      <?php
      $text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
      echo strip_tags($text);
      echo "\n";

      // 允許 <p> 和 <a>
      echo strip_tags($text, '<p><a>');
      ?>
      以上例程會(huì)輸出:

      Test paragraph. Other text
      <p>Test paragraph.</p> <a href="#fragment">Other text</a>
      熱門關(guān)鍵詞: php 字符串 HTML標(biāo)簽

      您可能感興趣的相關(guān)文章:

      欄目列表
      推薦內(nèi)容
      熱點(diǎn)內(nèi)容
      展開
      欧美一区二区三区免费A级视频,亚洲精品中文字幕综合,动漫精品中文字幕无码第一页,1024亚洲国产综合 亚太影院 柯西贝尔-游戏赚网
    1. <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
    2. <th id="l3qpx"><progress id="l3qpx"></progress></th>
        <th id="l3qpx"></th>
        <dd id="l3qpx"><font id="l3qpx"></font></dd>
        <th id="l3qpx"></th>