源来页 公告 登陆

geshi高亮类高亮[code]中文本例子

composer @Ta
2015-07-08 12:21

$高亮前的文本 = '以下是一段php代码:

<?php
$a = $b;
$b = $c;
$c = $d;
$d = $e;

完了';

$高亮后的文本 = preg_replace_callback('/[code(?:=(.*))?](.*)[/code]/isU', '代码高亮函数', $高亮前的文本);

function 代码高亮函数($arr) {
    $type = trim($arr[1]);
    if ($type == '') {
        $type = 'php';
    }
    $code = trim($arr[2]);
    require_once 'class/geshi/geshi.php';
    $geshi = new geshi($code, $type);
    $geshi->set_header_type(GESHI_HEADER_DIV);
    $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); 
    $html = $geshi->parse_code();
    return $html;
}

geshi源代码:http://sourceforge.net/projects/geshi/
阅:2175 发表于2015-07-08 12:21
#其他教程
评论:
颠覆灬整个世界 @Ta
2015-07-08 17:16

不错哦


返回源来页/返回首页


天合之作 曲在人意

心灵鸡汤:
      

®2019-2024 all power by Zlproject3.7
川公网安备 51192202000151号
蜀ICP备2021014921号-2 首页 #top

本网站由提供CDN加速/云储存服务

天合之作 曲在人意