原创 高亮你的PHP代码收藏

新一篇: 最简单的留言板 | 旧一篇: Arrays 101

PHP有一个很有用但是很多人都没有注意到的函数:highlight_string使用它你可以很轻松的高亮你的PHP代码。不过要注意,highlight_string返回一个Boolean值,它会直接把生成的HTML代码显示出来。下面是我写的一个简单的PHP脚本,你可以通过它来高亮你的代码,然后通过在线编辑器贴到CSDN上边:) 建议粘贴之后把字体设为 Courier New 这样看起来更方便

 

如果你比较懒,也可以访问http://exlcsoft.com/es5/highlight.php 来高亮你的代码~

 

  

<?php

error_reporting
(E_ALL & ~E_NOTICE
);
@
extract($HTTP_SERVER_VARSEXTR_SKIP
);
@
extract($HTTP_COOKIE_VARSEXTR_SKIP
);
@
extract($HTTP_POST_FILESEXTR_SKIP
);
@
extract($HTTP_POST_VARSEXTR_SKIP
);
@
extract($HTTP_GET_VARSEXTR_SKIP
);
@
extract($HTTP_ENV_VARSEXTR_SKIP
);

if ( 
$step != 
)
{
    echo 
'<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>php highlighter</title>
<style>
<!--
input        { border: 1px solid #000000;font-family: Courier New; font-size: 9pt }
textarea     { border: 1px solid #000000;font-family: Courier New; font-size: 9pt }
body         { scrollbar-face-color:white; scrollbar-shadow-color:black;
scrollbar-highlight-color:black; scrollbar-3dlight-color:white;
scrollbar-darkshadow-color:white; scrollbar-track-color:#f9f9f9;
scrollbar-arrow-color:black;font-family: Courier New; font-size: 9pt}
-->
</style>
</head>

<body>
PHP CODE highlight <br>
-------------------- <br>
@ Easy@bjpeu.edu.cn <br>
@ 2003 06 <p>
Please input the code: <br>
<form method="POST" >
  <textarea rows="15" name="con" cols="44"></textarea></p>
  <p><INPUT TYPE="hidden" name="step" value="2"><input type="submit" value="提交" name="B1"></p>
</form>

</body>
</html>'
;

}
else
{
    echo 
'<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>php highlighter</title>
<style>
<!--
a            { color: #FF0000; text-decoration: none }
font            {  text-decoration: none;font-family: Courier New; font-size: 9pt }
input        { border: 1px solid #000000 }
textarea     { border: 1px solid #000000 }
body         { scrollbar-face-color:white; scrollbar-shadow-color:black;
scrollbar-highlight-color:black; scrollbar-3dlight-color:white;
scrollbar-darkshadow-color:white; scrollbar-track-color:#f9f9f9;
scrollbar-arrow-color:black;font-family: Courier New; font-size: 9pt}
-->
</style>
</head>

<body>'
;
    
highlight_string stripslashes($con
) ) ;
echo 
'<p><a href="?">click here to go back...</a></body></html>'
;
    
}




?>

发表于 @ 2003年06月16日 17:21:00|评论(loading...)|编辑

新一篇: 最简单的留言板 | 旧一篇: Arrays 101

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © Easy