时间:12-04-13 栏目:网站开发 作者:admin 评论:0 点击: 189,056 次
本文标签: PHP
htmlout.php代码:
<?php /** * Steven.liao [email protected]. * * PHP输出HTML转HTML嵌入PHP格式 * $Date: 2011/11/14 19:30:00 $ */ /** * PHP输出HTML转HTML嵌入PHP格式附加函数 * @param $html String echo内容 */ function htmlout($content){ $content = stripslashes($content); return '?'.'>'.$content.'<?php'; } /** * PHP输出HTML转HTML嵌入PHP格式附加函数2 * @param $html String echo内容 */ function htmlout2($content){ $content = str_replace('\\n',"\n",$content); $content = str_replace('\\r',"\r",$content); $content = str_replace('\\t',"\t",$content); $content = str_replace('\\"',"\"",$content); $content = stripslashes($content); return '?'.'>'.$content.'<?php'; } /** * PHP输出HTML转HTML嵌入PHP格式 * @param $content String PHP脚本 */ function phpcode2htmlcode($content){ //处理格式:echo ''; //$content = preg_replace('@echo \'<s\';[\s]+echo \'cript@','echo \'<script',$content); $content = preg_replace("@echo '(.*)([^\\\\])';@isUe","htmlout('\\1\\2')",$content); //处理格式:echo ""; //$content = preg_replace('@echo "<s";[\s]+echo "cript@','echo "<script',$content); $content = preg_replace("@echo \"(.*)([^\\\\])\";@isUe","htmlout2('\\1','\\2')",$content); /*$content = preg_replace("@echo \"(.*)([^\\\\])\";@isU","?>\\1\\2<?php",$content);*/ //修正格式,删除多余空白,回车 $content = preg_replace('@<\?php[\s]+echo @','<?php echo ',$content); $content = preg_replace('@;[\s]+\?>@',';?>',$content); $content = preg_replace('@<\?phpecho@','<?php echo',$content); $content = preg_replace('@<\?php([^\s])@','<?php \1',$content); $content = preg_replace('@<\?php([\s]+)?\?>@','',$content); return $content; } //示例 if($argc==2){ $file = $argv[1]; $outfile = preg_replace('/.php$/','.html.php',$file); $file_c = file_get_contents($file); $file_c = phpcode2htmlcode($file_c); echo $outfile." size:".strlen($file_c)."\r\n"; file_put_contents($outfile,$file_c); }else{ //PHP格式 $file = 'index.php'; //整理后的输出文件 $outfile = 'index.html.php'; $file_c = file_get_contents($file); $file_c = phpcode2htmlcode($file_c); file_put_contents($outfile,$file_c); #show_source($outfile); } ?>
PHPhtml.cmd 代码:
@echo off d: cd D:\tools\crack_php5 echo 格式化文件 %1 开始........ d:\xampp\php\php.exe htmlout.php %1 echo 格式化文件 %1 完成!! rem ping -n 2 127.0.0.1>nul pause
声明: 本文由( admin )原创编译,转载请保留链接: PHP输出HTML转HTML嵌入PHP格式
------====== 本站公告 ======------
联系信息:
电话:19970108113(微信同号) QQ:3142401606
支付宝:https://me.alipay.com/lxq73061
相关插件程序等信息均会在站内发布,敬请关注。