php源代码压缩,PHP 源代码压缩小工具

使用方法:(在命令行运行)

php compactor.php destination.php source.php

下载:

#!/usr/bin/env php

/**

* compact php code.

*

* strip comments, combine entire library into one file.

*/

if ($argc < 3) {

print "strip unecessary data from php source files.\n\n\tusage: php compactor.php destination.php source.php";

exit;

}

$source = $argv[2];

$target = $argv[1];

print "compacting $source into $target.\n";

include $source;

$files = get_included_files();

print_r($files);

$out = fopen($target, 'w');

fwrite($out, '<?php ' . php_eol);

fwrite($out, '// querypath. copyright (c) 2009, matt butcher.' . php_eol);

fwrite($out, '// this software is released under the lgpl, v. 2.1 or an mit-style license.' . php_eol);

fwrite($out ,'// http://opensource.org/licenses/lgpl-2.1.php');

fwrite($out, '// http://querypath.org.' . php_eol);

foreach ($files as $f) {

if ($f !== __file__) {

$contents = file_get_contents($f);

foreach (token_get_all($contents) as $token) {

if (is_string($token)) {

fwrite($out, $token);

}

else {

switch ($token[0]) {

case t_require:

case t_require_once:

case t_include_once:

// we leave t_include since it is rarely used to include

// libraries and often used to include html/template files.

case t_comment:

case t_doc_comment:

case t_open_tag:

case t_close_tag:

break;

case t_whitespace:

fwrite($out, ' ');

break;

default:

fwrite($out, $token[1]);

}

}

}

}

}

fclose($out);

?>

希望与广大网友互动??

点此进行留言吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值