PHP 源代码压缩小工具

前端之家收集整理的这篇文章主要介绍了PHP 源代码压缩小工具前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

使用方法:(在命令行运行) @H_404_0@<div class="codetitle"><a style="CURSOR: pointer" data="97686" class="copybut" id="copybut97686" onclick="doCopy('code97686')"> 代码如下:

<div class="codebody" id="code97686">@H_404_0@PHP compactor.PHP DESTINATION.PHP SOURCE.PHP @H_4040@
@H404_0@下载: compactor.php
<div class="codetitle"><a style="CURSOR: pointer" data="89400" class="copybut" id="copybut89400" onclick="doCopy('code89400')"> 代码如下:
<div class="codebody" id="code89400">@H_404_0@#!/usr/bin/env PHP @H_404_0@<?PHP @H_4040@/** @H404_0@ Compact PHP code. @H_404_0@ @H_4040@* Strip comments,combine entire library into one file. @H4040@*/ if ($argc < 3) { @H404_0@print "Strip unecessary data from PHP source files.\n\n\tUsage: PHP compactor.PHP DESTINATION.PHP SOURCE.PHP"; @H_4040@exit; @H4040@} @H4040@$source = $argv[2]; @H4040@$target = $argv[1]; @H404_0@print "Compacting $source into $target.\n"; include $source; $files = get_includedfiles(); @H404_0@printr($files); $out = fopen($target,'w'); @H404_0@fwrite($out,'<?PHP' . PHPEOL); @H404_0@fwrite($out,'// QueryPath. Copyright (c) 2009,Matt Butcher.' . PHPEOL); @H404_0@fwrite($out,'// This software is released under the LGPL,v. 2.1 or an MIT-style license.' . PHPEOL); @H404_0@fwrite($out,'// http://opensource.org/licenses/lgpl-2.1.PHP'); @H_404_0@fwrite($out,'// http://querypath.org.' . PHPEOL); @H4040@foreach ($files as $f) { @H4040@if ($f !== FILE) { @H404_0@$contents = file_getcontents($f); @H404_0@foreach (token_getall($contents) as $token) { @H404_0@if (isstring($token)) { @H4040@fwrite($out,$token); @H4040@} @H4040@else { @H4040@switch ($token[0]) { @H404_0@case TREQUIRE: @H404_0@case T_REQUIREONCE: @H404_0@case T_INCLUDEONCE: @H404_0@// We leave TINCLUDE since it is rarely used to include @H4040@// libraries and often used to include HTML/template files. @H404_0@case TCOMMENT: @H404_0@case T_DOCCOMMENT: @H404_0@case T_OPENTAG: @H404_0@case T_CLOSETAG: @H4040@break; @H404_0@case TWHITESPACE: @H4040@fwrite($out,' '); @H4040@break; @H4040@default: @H4040@fwrite($out,$token[1]); @H4040@} } @H4040@} @H4040@} @H4040@} @H4040@fclose($out); @H4040@?>@H404_0@

猜你在找的PHP相关文章