代码折叠与高亮 网页上贴代码,如何实现高亮和折叠?好像是通过JS实现的。有没有这样的JS?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php$s = highlight_string('程序代码',1); //或$s = highlight_file('程序文件.php',1);echo preg_replace_callback('/[{}]/', 'foo', $s);function foo($v) { static $deep = 0; switch($v[0]) { case '{': $r = "{<div id='a$deep' onclick=show('a$deep','b$deep')>...</div><div id='b$deep' style='display:none' onclick=show('b$deep','a$deep')>"; $deep++; break; case '}': $r = '</div>}'; break; } return $r;}echo <<< JS<script>function show(a, b) { document.getElementById(a).style.display = 'none'; document.getElementById(b).style.display = '';}</script>JS;?>简单的实现 php同页面传值怎么写? 如何截取页面 代码如下: 急问 mysql_connect 前的@ 和php.ini 中的displays_errors=off 有什么区别 有没有字符编码转换工具+phpmyadmin字符问题? W2K+iis5.0,请问改怎么安装PHP程序? 用mail()发邮件在php.ini中应该怎样设置? 请问在winme下如何安装可使用apache?? freebsd+apache+php的配置问题,在线等 php4.1.1的安装问题!! gd图像显示不出来 【此人是PHP牛人!】发帖散分! 函数file_get_contents()的使用问题
$s = highlight_string('程序代码',1); //或
$s = highlight_file('程序文件.php',1);echo preg_replace_callback('/[{}]/', 'foo', $s);function foo($v) {
static $deep = 0;
switch($v[0]) {
case '{':
$r = "{<div id='a$deep' onclick=show('a$deep','b$deep')>...</div><div id='b$deep' style='display:none' onclick=show('b$deep','a$deep')>";
$deep++;
break;
case '}':
$r = '</div>}';
break;
}
return $r;
}
echo <<< JS
<script>
function show(a, b) {
document.getElementById(a).style.display = 'none';
document.getElementById(b).style.display = '';
}
</script>
JS;
?>
简单的实现