测试一下csdn blog的代码高亮

今天才看到csdn blog加入了[code]功能
并且很幸运的有小语种php……
随便开了个以前写的php文件
测试一下

<? php
/* comment.inc.php
*处理评论的函数
*/

require_once ( ' conf.inc.php ' );
require_once ( ' func.inc.php ' );

function  comments_gen_struct()
{
    
$cmts = array ();
    
return   $cmts ;
}

function  comment_one_gen_struct( $eid , $content , $uid = "" , $time = "" )
{
    
if ( $uid === "" ) $uid = get_current_usr_name();
    
if ( $time === "" ) $time = date ( " Y-m-d H:i:s " );
    
$cmt = array (     ' eid ' => $eid ,
                
' uid ' => $uid ,
                
' time ' => $time ,
                
' content ' => $content );
    
return   $cmt ;
}

function  comment_one2html( $one_cmnt , $eid , $cid )
{
    
$html = " <table width='100%' border='0' cellpadding='0' cellspace='0'><tr><td align='left'> " ;
    
if (is_admin())
    {
        
$html .= " <a href='del_comment.php?eid=$eid&cid=$cid'>删除</a> " ;
    }
    
// $html.="<a href='user.php?uid=".$one_cmnt['uid']."' target='_new'>".$one_cmnt['uid']."</a>说:</td>";
     $html .= $one_cmnt [ ' uid ' ] . " 说:</td> " ;
    
$html .= " <td align='right'>发表于 " . $one_cmnt [ ' time ' ] . " </td></tr></table> " ;
    
$html .= " <hr size='2' align='center' noshade width='100%' color='Purple' /> " . $one_cmnt [ ' content ' ];
    
return   $html ;
}

function  comment_struct2html( $cmnt_struct , $eid )
{
    
$html = " <table width='100%' border='0' cellpadding='10'><tr><td class='row0'>评论:</td></tr> " ;
    
$color = 1 ;
    
foreach ( $cmnt_struct   as   $k => $c )
    {
        
$color = 3 - $color ;
        
$html .= " <tr><td class='row$color'> " . comment_one2html( $c , $eid , $k ) . " </td></tr> " ;
    }
    
$html .= " </table> " ;
    
return   $html ;
}

function  comment_get_by_eid( $eid )
{
    
global   $conf ;
    
$rslt = db_query( " SELECT `comments` FROM ` " . $conf [ ' TBL ' ][ ' ARTICLE ' ] . " ` WHERE `eid`=$eid; " );
    
$row = db_fetch_array( $rslt );
    
return   unserialize ( $row [ ' comments ' ]);
}

function  comment_add( $eid , $content , $uid = "" , $time = "" )
{
    
global   $conf ;
    
$c = comment_get_by_eid( $eid );
    
$c [] = comment_one_gen_struct( $eid , $content , $uid , $time );
    db_query(
" UPDATE ` " . $conf [ ' TBL ' ][ ' ARTICLE ' ] . " ` SET `comments`=' " . serialize ( $c ) . " ' WHERE `eid`='$eid'; " );
}

function  comment_del( $eid , $cid )
{
    
global   $conf ;
    
$c = comment_get_by_eid( $eid );
    
unset ( $c [ $cid ]);
    db_query(
" UPDATE ` " . $conf [ ' TBL ' ][ ' ARTICLE ' ] . " ` SET `comments`=' " . serialize ( $c ) . " ' WHERE `eid`='$eid'; " );
}

function  comment_not_allow( $eid )
{
    
global   $conf ;
    db_query(
" UPDATE ` " . $conf [ ' TBL ' ][ ' ARTICLE ' ] . " ` SET `allow_comment`='false' WHERE `eid`='$eid'; " );
}

function  comment_allow( $eid )
{
    
global   $conf ;
    
$rslt = db_query( " UPDATE ` " . $conf [ ' TBL ' ][ ' ARTICLE ' ] . " ` SET `allow_comment`='true' WHERE `eid`='$eid'; " );
}
?>
 
效果不错
划分还可以再细腻一点,比如说字符串,单引号,双引号,内置变量($_开头)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值