欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php自定義函數(shù)轉(zhuǎn)換html標(biāo)簽示例

 更新時(shí)間:2016年09月29日 11:48:52   作者:山貓的博客  
這篇文章主要介紹了php自定義函數(shù)轉(zhuǎn)換html標(biāo)簽的方法,結(jié)合實(shí)例形式分析了php針對(duì)字符串的編碼轉(zhuǎn)換與正則替換操作技巧,需要的朋友可以參考下

本文實(shí)例講述了php自定義函數(shù)轉(zhuǎn)換html標(biāo)簽的方法。分享給大家供大家參考,具體如下:

<?php
/*
* Created on 2016-9-29
*
*/
$orig = "I'll \"walk\" the <b>dog</b> now";
$a = htmlentities($orig);
$b = html_entity_decode($a);
echo $a; // I'll &amp;quot;walk&amp;quot; the &amp;lt;b&amp;gt;dog&amp;lt;/b&amp;gt; now
echo $b; // I'll "walk" the <b>dog</b> now
// For users prior to PHP 4.3.0 you may do this:
function unhtmlentities($string)
{
  // replace numeric entities
  $string = preg_replace('~&amp;#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
  $string = preg_replace('~&amp;#([0-9]+);~e', 'chr("\\1")', $string);
  // replace literal entities
  $trans_tbl = get_html_translation_table(HTML_ENTITIES);
  $trans_tbl = array_flip($trans_tbl);
  return strtr($string, $trans_tbl);
}
$c = unhtmlentities($a);
echo $c; // I'll "walk" the <b>dog</b> now
?>

運(yùn)行結(jié)果如下圖所示:

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《PHP編碼與轉(zhuǎn)碼操作技巧匯總》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計(jì)算法總結(jié)》、《php正則表達(dá)式用法總結(jié)》、及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論