搜尋
首頁後端開發php教程PHP - Html Transfer Code_PHP教程


PHP - Html Transfer Code 超文本轉換碼,市面上這東西已經很濫(多)了,不過是這幾天自己實踐了一下~~~~

支持多重嵌套和同標籤嵌套,混合高亮顯示(還有一點小問題)

自我感覺方便修改和擴充~~~~~~~~~~~

/****************************************************
*                                         🎜>* 版本: 1.3.2                                       *
* 建立  : 2003-09-03                                      *
* 修改時間: 2003-12-17                            ** 首頁:無(可能很快)                    *
* 注意:您可自由使用和修改它,         *
*           但請保留此物品。 *
*                                        ****** *** *******/

$htc_list = array(
                "B"               => "                             => "\1" ,
                "U"                => "\1",n",
                "URL"                => "\1",
                "EMAIL"                 " IMAGE"                => "

PHP - Html Transfer Code_PHP教程parseInt(this.offsetParent.offsetWidth))?this.offsetParent.offsetWidth:org_w' onclick='window.open(this.src) ' style="max-width:90%" />

n",
                "DOWNLOAD"       => "exec:get_dl_html(.\ 🎜>                "LIST"                => "exec:get_list_html('\1')", "

  引用:
\1
n",
“IFRAME”=> "n",
                "移動"                => "\1選框>n",
                "GLOW"                =>; "
n",
                「陰影」        => "
\1
n",\1n",\1n",\1n",; "
\1
n",
            src='\1' Loop='-1'>n",
                "音樂"                => "
下載音樂 ;
n",               
            tr>n",
                "衝擊波"        =>; “ ; “ > ;n",
                “QUICKTIME”        => "下載電影 n",
                "REALPLAYER"        => "

Download The Movie
\n",
                "MEDIAPLAYER"        => "

Download The Movie
\n",
                "VOTE"                => "exec:get_vote_html('\\1')",
                );

$htc_list_att = array(
                "ALIGN"                => "
\\2
n",
                "URL"                => "\         => "\2",
                "影像"                => "
PHP - Html Transfer Code_PHP教程 td> "
PHP - Html Transfer Code_PHP教程 td> '\2' border='0' onload='org_w=this.offsetWidth;this.style.width=10;this.style.width=(org_w>parseInt( this.offsetParent.offsetWidth))?this.offsetParent.offsetWidth :org_w;' onclick='window.open(this.src)' style="max-width:90%" />
>n",
                " FONTFACE "        => "\2",
                "FONTSIZE"             "FONTSIZE"       style  /span>",
                "字型顏色"        => "\2 :get_dl_html('\1 ', '\2')",
                "名單"                => "exec:get_list_html('\2',''\1')        => "exec:get_attach_html('\2 ', '\1')",
                "投票"                => "exec:get_vote_html('\1','\2')",
);

$htc_list_spl = array(
                "PHP"                => "exec:get_highlight_html('\1', 'php')",         =>「執行: get_highlight_html('\1', 'css')",
                "HTML"                => "exec:get_highlight_html('\1', 'html  c:get_highlight_html('\1', 'script')",
"代碼"                =>; "exec:get_code_html('\1')",
                "執行"                "執行"                 );


function get_highlight_html($str , $type = "php") {
        $type = strtolower($type);
        $type_func = $type."_highlight";
 result = "
";
        if(!function_exists($type_func)) $type_func = "php_hightype_func. ;
        $result .= "
       
高亮顯示{$type} 代碼:

          

          ".$type_func($str)."

        ".($type=="HTML"?"":"")."
       
            )


function css_highlight($str, $nl = true) {
        $color_1 = "紅色";
      $color_2 = "綠色";
       $color_2 = "綠色";
     30 $color_2 = "綠色";
   " ;
        $str = str_replace("\"","",$str);
        $str = str_replace("r", "", $str. \ *.w#: ] {[^{}] }/", $str, $arr_css);
        $arr_css = $arr_css[0];
        for($i =0; $i                $head = preg_replace("/([\*.w#: ] {)[^{}] }/", " \1".($nl?"
n":""), $arr_css[$i]);
                $unit = preg_replace("/[\*.ww#. ] {([^{}] )}/", "\1", $arr_css[$i]);
                $unit_list = preg_split("/ unit = "n";
                for($j=0; $j                        if(strlen($unit_list[$j])>0)
  = "    " . preg_replace("/s*([w-] )s*:s*(.*)/e", "'\1 : '.htmlspecialchars('\2').' '", $unit_list[$j]) 。 ($nl?"
n":"n");
                }
               $arr_css[$i] = $head . "}";
        }
        return join(($nl?"n
gt;
n " :"nn "), $arr_css);
}


function script_highlight_note($str, $mode = true) {
        $color_note = "gray";
        $color_note = "gray";
        $color_note = "gray";
 "\"",""",$str);
        $str = preg_replace("/(.*)/isU ", "\ 1", $str);
        $str = $mode?"/*{$str}*/":"//{$str}";
        return "{ $str}";
}


function script_highlight($str, $nl = true) {
        $color_1 = "紅色";
$color_2 = "藍色";
        $color_3 = "棕色";
        $color_4 = "綠色";
       str = htmlspecialchars($str);
        $str = str_replace("=","&equal;",$str);
        $str = str_replace("|", "&vertical"|
        $keywords = array(
                        "{$color_1}"            "{$color_1}"                         "{$color_ 2}” =>佇列(“var”,“for”,“if”,“else”,“switch”,“case”,“函數”,“循環”,“繼續”,“break”,“> ” " , "!=", "==", "=", "&&", "&垂直;&垂直;"),
                        “{$color_3}"        => array("window", "self", "this", "event", "document", "opener", "Navigator", "Math", "Array", "String", "Object", "函數", "數字"),
                        );
        foreach($keywords as $p = $ $value ; $i                        $str = preg_replace("/(W)(".$value[$i].")(W)/", "\1 \; \3", $str);
                }
        }
       $str = preg_replace("/..|字型顏色='{$color_4}'>\2(", $str);
        $str = preg_replace("/.(w )(?!()/i" ,". \1", $str);
        $str = preg_replace("///([^n]*)n/e" ," script_highlight_note('\ 1 ', false)", $str);
        $str = preg_replace("//*(.*?)*//es" ,"script_highlight_note('\1')", $str ); > $str = str_replace("t", "    ", $str);
        $str = str_replace("&equal;","=",$str);
  str     $str = , "|",$str);
        return $nl?nl2br($str):$str;
}


function html_highhigh_attr($att) { = "紅色";
        $color_2 = "棕色";
        $color_3 = "黑色";
        $att = str_replace("\"),""
        $att = preg_replace("/=s*('|")([^'"] )\1/eU","'=\1'.preg_replace('/s /','|:s :|','\2').'\1'",$att);
        $att = str_replace("\"",""",$att);
        $att .= " " ;
        preg_match_all("/[a-z:/-] (=(['"]?).*[^\\]{1}\2?)?s /iU", $att, $att_list);
        $att_list = $att_list[0];
        for($i=0; $i                $att_list[$i] = trim($att_list[$i]);
             $🎜>             $(h._list) $(/place)(Iplace)( '"]?)(.*)(\3)/", "\ 1字型>\2字型>\3\4 字型>\3", $att_list [$i]);
        }
        return str_replace("|:s:|",|:ss:| " ", join(" ", $att_list));
}


function html_highlight($str) {
        $color_1 = " 紅色";
        $color_1 = " 紅色";
      $color_1 = " 紅色";
   藍色";
        $color_3 = "灰色";
        $str = str_replace("\"", """,$str);
       > )>(.*)/isU", $str, $arr_tmp);
        $arr_script = $arr_tmp[0];
        for($i=0; $i                $str = str_replace($arr_script[$i], "
::script_{$i}::
", $str);
::script_{$i}::]*)>(.* )/iseU", "'<script><br />'.script_highlight(str_replace('\"','"','\2'), false).'<font color='{$color_2}'></ SCRIPT>; '", $arr_script[$i]);<br>      }<br>        $str = preg_replace("/(<textarea[^>]*>)(.*)()/即U" ,"'\1'.htmlspecialchars('\2').'\3'", $str);<br>        $str = preg_replace("/<!--(.*)- -> /seU" ,"'<!--'.htmlspecialchars('\1').'-->'", $str);<br>        $str = preg_replace("/<style([^>gt ) ) ;]*)>(.*)/isU" ,"<!style\1>\2!>", $str);<br>        $str = preg_replace(" /< ( [a-z:] )s*(.*?)( /|/)?>/ise" ,"'< 字型顏色='{$color_2}'><\1 '.html_highlight_attr('\2').'\3></ font>'", $str);<br>        $str = preg_replace("/<(/[a-z: ] )>/ i" ,"<字體顏色='{$color_2}'><\1>", $str);<br>        $str = preg_replace("/<; (!--.*--) >/sU" ,"<字體顏色='{$color_3}'><\1>", $str);<br>        $str = preg_replace("/<!style([^>]* )>(.*)!>/iseU" ,"'<字體顏色='{$color_2}'>< ;樣式'.html_highlight_attr('\1').'><br / >'.css_highlight(str_replace('\"','"','\2'), false)。 ", $str);<br>        for($i=0; $i<; count($arr_script); $i ) {<br>               $str = str_replace("<br>} :<br>", $arr_script[$i], $str);<br> }<br>        $str = str_replace("</ font>", "", $str);<br> $str = str_replace("</ b>", " ;", $str);<br>        $str = str_replace(" >", ">", $str);<br>       $str = str_replace("  ","  ",$str);<br> $str = str_replace("t","    ",$str);<br>        return nl2br($str);<br> ><br>function get_file_pic($filename) {<br>        全域$root_path;<br>        $ext = str_replace(" ),strrchr($filename,".) ); $root_path."images/mime_type/{$ext}.gif" ;<br>        return file_exists($pic)?"$pic":$root_path."images/mime_type/attch.gif";<br>$root_path."images/mime_type/attch.gif";<br>}<br>}<br>}< ><br><br>function get_dl_html($filename, $str = "") {<br>        return "<img src='".get_file_pic($filename)."' border='0' alt="PHP - Html Transfer Code_PHP教程" >; <a href='$filename'>".(empty($str)?basename($filename):$str)."";<br>}<br><br><br>函數 get_attach_html ($filename, $id) {<br>        return "<img src='".get_file_pic($filename)."' border='0' alt="PHP - Html Transfer Code_PHP教程" >; <a href='attach_manage.php?method=download&id=$id'>$filename";<br>}<br><br><br>function get_vote_html($vote_idx, $message = " ") {<br>        全域$db_host, $db_user, $db_pass, $db_name;<br>        $db = new DB_Manager($db_host, $db_user, $db_pass);< >SelectDB($db_name);<br>        $db->Query("select * from mnms_poll where id=".$vote_idx);<br>        $record = $db->Gstret ()<db-> "";<br>        $db->close();<br>        unset($db);<br>        if($record) {<br>        if($record) {<br>        if($record) {<br> 🠎                  $if_vote = !( strpos($record[vote_user], "|{$username}|")===false) <br> strpos($record[vote_user], "|".GetIp() ."|")  🠎>               str .= "<br>                        <fieldset><br>             he vote_title ] :$訊息)。 🎜>                          < 表單名稱='poll' action='poll_manage.php?      <表格寬度='90年%'align='center'>";<br> $ dote_list = split(“ ::”,$ record [fote_list]); <br> $ potter_count = split(“ ::”,$ record [dovel_count]); <<br> $ potture_users = count(split(split(“ ”) n", $record[vote_user])) - 1;<br>                $vote_sum = array_sum($vote_count);<>    str                    < tr><td colspan='2'> 目前共有 <字體顏色='紅色'>{$vote_users}</字體> 人參與了這次投票";<br>                if($vote_sum==0) $vote_sum = 1;<br>     ==0) $vote_sum = 1;<br> $vote_list) ); $i ) {<br>                        $str .= "<br>     "► ":"<輸入類型='隱藏'值='".$ vote_count[$i]."' name='vote_count[]'><輸入型別='".($record[vote_multi]=='Y'?"checkbox":"radio")."' name= 'vote []' value='{$i}'>").htmlspecialchars($vote_list[$i])."<td width='400'><img src='圖片/條/條". ($i 1).".gif' style="max-width:90%".ceil($vote_count[$i]*300/$vote_sum)."' style="max-width:90%" alt="PHP - Html Transfer Code_PHP教程" > 佔總票數的<font color='#990000' >".ceil((int)$vote_count[$i]*100/$vote_sum)."% tr>n";<br>                }<🎜>              }<🎜>    .  <tr><td colspan='2'align='center'><br>".($if_vote?"<b&gt ;您已經投過票了!":"<input type='hidden' value='{$record[id]}' name='id'><input type='Submit' value='確定' name= '提交'>   < input type='reset' value='重置' name='reset'>")."";<br>                $str                                                   ";<br>        }<br>        return $str<        $str = str_replace("\"" ,""",$str);<br>        return "<br>        <表格對齊='center' width='550'><br>    相信  10' name=Code>".htmlspecialchars($str)."<br><br>            <輸入型別= 'button' value='執行碼' onClick="str=this.parentNode.firstd. ;code_win=window.open('about:blank');doc=code_win.document;doc.open();doc.write (str);doc.close();code_win.focus();"><br> <input type='button' value='複製程式碼' onclick="try{window.clipboardData.setData('text' ,this.parentNode.firstChild.value);alert('將Codez 儲存到剪貼簿!'); }catch(e){alert('請複製選定的Codez!');this.parentNode.firstChild.select(); }"><br>            <input type='button' value='儲存程式碼' onClick='儲存程式碼' onC. "str=this.parentNode.firstChild.value;code_win=window.open('about:blank','_blank', 'top=10000');code_win.document.writeln(str);code_win.document.execCommand(' saveas','','code.html');code_win.close();"><br>            (提示:先修改部分代碼)<br>      >";<br>}<br><br><br>function get_list_html($content, $ type = "") {<br>        $content = preg_replace("/(<br />)?[rn] />)?[rn] /> ", "n", $content);<br>        $content = preg_replace("/[ rn] /", "n", $content);<br>        $content = preg_replace("/^[n]*( .*)[n]*$/m", "\1", $content); <br>        $content = str_replace("n", "<li>", $content);<br> $content = "<ul type='$type'><li>; $contentn";<br>        return $content;<br>}<br><br><br> function html_trans($str) {<br>        $search  = array(" &",                "'",            ",        ">",        "  ",                "t");<br>      $替換= 數組("&",        "'",        """,        " <",        ">",        "  ",      ">",       (str_replace($search, $replace, $str));<br> }<br><br><br>function link_url ($str) {<br>        $str = preg_replace("/((http|ftp|mms|rtsp|pnm|mail)://[w@:/ ?=&;#-%] )/i" , "<a href='\1' target='_blank'>\1", $str);<br>        $str = preg_replace("/ (w @(w .) [w] {2,3})/i", "<a href='mailto:\1'>\1", $str);<br>        $str = preg_replace("/(href|src) )='<a href=('. ')>[^<] '/iU", "\1=\2", $str);<br> return $str;<br>}<br><br><br>function htc2html_loop($str) {<br>        全域$htc_list, $htc_list_att;< 🠎> 線上$ ) for $ <br>                if(substr($value,0,5)= ="exec:"){<br>             /$ ?([^]] ))?]))*)[ /$key]/iexsU", substr($value,5), $str);<br>                }else {<br>                        $str = preg_replace("/[$key]((.(?![$key(s?=s?([^]] )))? /ixsU", "$value", $str);<br>                }<br>        }<br>       if(substr($value,0, 5 ) )=="exec:"){<br>                        $str = preg_replace("/[$keys?=s?([^]] )](.(.(?!)(s? [ ^]] ))?]))*)[/$key]/iesxU", substr($value,5), $str);<br>                }  "/[ $鍵? " $value", $str);<br>                }<br>        }<br>        return $str. , $loop = 3) {<br>        全域$htc_list_spl;<br>        $str = preg_replace("/([w ])s*/ixs","\1",$str);<br>< / s*([/w ])/ixs","\1",$str);<br>        foreach($htc_list_spl as $key => $value) {<br>          => $value) {<br>         . *)[/$key]/ixsU", $str, $arr_tmp);<br>                $arr_spl[$key] = $arr_tmp[0];<br>  $arr_spl[$key] = $arr_tmp[0];<br>  $arr_spl[$key] = $arr_tmp[0] $i<count($arr_spl[$key]); $i ) {<br>                        $str = str_replace($arr_spl[$key][$i], "<br>::{$key}_{$n} 🎜>                        if(substr($value,0,5)=="exec:"){<br>    key][$i] = preg_replace("/[$key](.*)[/$ key]/iexsU", substr($value,5), $arr_spl[$key][$i]);<br>                              $arr_spl[$key][$i] = preg_re地點(“ / [$ key](。*)[/$ key]/ixsu”,“ $ value”,$ arr_spl [$ key] [$ i] [$ i]); <br>} <br>} <br>} str = html_trans($str);<br>        while($loop-- > 0) {<br>      while        =s?([^]] ))? ](.*)[/\1]/isU", $str)) Break;<br>                $str = htc2html_loop($str);<br>    $str = htc2html_loop($str);<br>   if($trans_url) $str = link_url($ str);<br>        foreach($htc_list_spl as $key => $value) {<br>       ”$$ arr arr for$($ for $. ) ]); $i ) {<br> $str = str_replace("<br>::{$key}_{$i}::<br>", $arr_spl[$key][$i], $ str );<br>                }<br>        } <br>        使用<br>echo htc2html ( $str);<br><br>好啦~~~~~~~~~<br> <br> <br><br><br>http://www.bkjia.com/PHPjc/314366.html<br><br>www.bkjia.com<br><br>true<br><br>http: //www.bkjia.com/PHPjc/314366.html<br><br>TechArticle<br><br>PHP - Html 轉換傳輸程式碼超文本碼,讀這東西已經很豐富了,不過是這幾天自己實踐交流~~~~支援電壓喚醒和同標籤靜音、混合...<br><p align="left"><div style="display:none;"> <span id="url" itemprop="url"></script>
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace("&nbsp;","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么查找字符串是第几位php怎么查找字符串是第几位Apr 22, 2022 pm 06:48 PM

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境