php¶ÔzipÎļþ½âѹºÍѹËõ
<?php
/**
* @author wyt
*
*/
class zip {
private $_zipObj=null;
private $_zipfcArr=array();
private $_basePath=null;
private $_zipName;
/**
* init
* @param zipÎļþÃû³Æ $zipName
*/
function __construct($zipName){
$this->_zipName=$zipName;
$this->_zipObj=new rezip();
}
/**
* ѹËõÒ»¸öÎļþ¼Ð
* @param Ŀ¼Ãû³Æ $path
*/
public function tozip($path){
$this->_basePath=$path;
$this->_basePath.='/';
$this->direct($path);
$this->_zipObj->Add($this->_zipfcArr,1);
//дÈëÎļþ
if(@fputs(@fopen($this->_zipName,"wb"),$this->_zipObj->get_file())) return $this->_zipName;
return false;
}
/**
* ½âѹzipÎļþ
* @param ½âѹµ½µÄÎļþ¼Ð $destPath
*/
public function unzip($destPath){
if(!file_exists($destPath)) @mkdir($destPath,0777,true);
return $this->_zipObj->Extract($this->_zipName,$destPath);
}
function direct($path){
$handler=opendir($path);
while(($file=readdir($handler))!==false){
if($file=='.'||$file=='..') continue;
$tmp=$path.'/'.$file;
$filename=str_replace($this->_basePath,'',$tmp);
if(is_dir($tmp)){
$this->direct($tmp);
}else{
//Éú³ÉµÄzip ÎļþÃû
echo $tmp."\n";
$filesize=@filesize($tmp);
$fp=@fopen($tmp,rb);
$this->_zipfcArr[]=Array($filename,@fread($fp,$filesize));
@fclose($fp);
}
}
closedir($handler);
}
}
/**
* ѹËõÀ࣬½øÐÐÁËССµÄ¸Ä¶¯
*
*/
class rezip{
var $datasec, $ctrl_dir = array();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0; var $dirs = Array(".");
function get_List($zip_name){
$zip = @fopen($zip_name, 'rb');
if(!$zip) return(0);
$centd = $this->ReadCentralDir($zip,$zip_name);
@rewind($zip);
@fseek($zip, $centd['offset']);
for ($i=0; $i<$centd['entries']; $i++){
$header = $this->Re
Ïà¹ØÎĵµ£º
ÈçºÎ´´½¨ÎÒÃǵĵÚÒ»¸öPHPÒ³ÃæÄØ£¿·Ç³£¼òµ¥µÄ£¡Ñ¡ÔñÎÒÃÇʹÓõÄÒ»¸ö×îºÃµÄÉè¼Æ¹¤¾ß£¬µ±È»ÄãÒ²¿ÉÒÔ Ö»Ê¹ÓüÇʱ¾¡£´´½¨Ö®ºó¼ÇµÃÒª±£´æΪÀ©Õ¹ÃûΪPHPµÄÎļþ£¬È»ºó´«µ½ÎÒÃǵķþÎñÆ÷
ÉÏ¡£
¡¡¡¡ÔÚ±àдPHP³ÌÐò֮ǰͨ³£ÎÒÃÇÐèÒªÅäÖÃÎÒÃǵĻ·¾³£¬Ò²¾ÍÊÇ˵·þÎñÆ÷
ÒªÖ§³ÖPHP²ÅÄÜÐа¡
¡¡¡¡Ò»¡¢PHPµÄ»ù±¾½á¹¹£º
¡¡¡¡Ê¹ÓÃIncl ......
1.Èç¹ûÒ»¸ö·½·¨¿É¾²Ì¬»¯£¬¾Í¶ÔËü×ö¾²Ì¬ÉùÃ÷¡£ËÙÂÊ¿ÉÌáÉýÖÁ4±¶¡£
2.echo ±È print ¿ì¡£
3.ʹÓÃechoµÄ¶àÖزÎÊý£¨Òë×¢£ºÖ¸ÓöººÅ¶ø²»ÊǾäµã£©´úÌæ×Ö·û´®Á¬½Ó¡£
4.ÔÚÖ´ÐÐforÑ»·Ö®Ç°È·¶¨×î´óÑ»·Êý£¬²»ÒªÃ¿Ñ»·Ò»´Î¶¼¼ÆËã×î´óÖµ¡£
5.×¢ÏúÄÇЩ²»ÓõıäÁ¿ÓÈÆäÊÇ´óÊý×飬ÒÔ±ãÊÍ·ÅÄÚ´æ¡£
6.¾¡Á¿±ÜÃâʹÓÃ__get£¬__se ......
Ò»Ö±¶¼ÒÔΪÔÚPHPÖУ¬' ºÍ"ÊÇûÓÐÇø±ðµÄ£¬½ñÌì¿´ÁËÖÐÔ´óѧËïÖÙÔÀÀÏʦµÄÊÓƵ½Ì³Ì£¬²Å·¢ÏÖ£¬ÕâÁ½ÕßÓ÷¨ÊÇÓÐÇø±ðµÄ£¬¾Ù¸ö¼òµ¥µÄÀý×Ó£º
1.php
<?$str='±ù¶³Óã';
echo '$str µÄ²©¿ÍµØÖ·ÊÇhttp://www.webxuexi.net' ;//×¢ÒâÕâÀïÊǵ¥ÒýºÅŶ
?>
2.php
<?
$str='±ù¶³Óã';
echo ......
ÍøÉϹØÓÚÕâÀàµÄÌû×ÓÕæµÄºÜ¶à£¬µ«ÊÇÎÒÊÔÁ˺ܶ࣬ÀýÈç°Ñphp plus for eclipse ÏÂÔØÏÂÀ´£¬½âѹºó·Åµ½EclipseµÄpluginÀïÃ棬µ«ÊDz»ÖªµÀΪʲô£¬¶¼²»¹ÜÓá£
ÎÒ´ÓÍøÉÏÕÒµ½ÁËÒ»ÖֱȽϼòµ¥µÄ·½·¨£ºÄǾÍÊÇÓÉEclipse×Ô¼ºÀ´¸üÐÂ×Ô¼ºµÄ×é¼þ£¬ÕâÑùµÄ·½·¨Ê¡È¥Á˺ܶàµÄÅäÖ㬿ÉÒÔÖ±½ÓÄ ......