当前位置:首页 » 文件管理 » php解压函数

php解压函数

发布时间: 2023-08-02 23:24:47

php实现解压缩功能

/*
由于你给我的说明不太清楚,所以可能在有些地方未能合你的本意.
*/

#include "stdafx.h"//如果发生编译错误,请删除此句再试一试
#include <iostream>

using namespace std;

//类CVehicle的申明
class CVehicle
{
public:
CVehicle();//构造函数申明
CVehicle(const CVehicle &);//拷贝构造函数申明
~CVehicle();//析构函数申明

void SetCarNo(const char *);//设置车牌号的成员函数
const char * GetCarNO(void);//获取车牌号的成员函数

void SetTotalPerson(long);//设置载客数的成员函数
void SetTotalWeight(double);//设置总的重量的成员函数
long GetTotalPerson(void);//获取载客数量
double GetTotalWeight(void);//获取总的重量

bool operator == (const CVehicle &);//重载==运算符
bool operator != (const CVehicle &);//重载!=运算符

friend char * GetVehicleID(const CVehicle &);//获取车牌号的友员函数申明

private:
char * p_id;//保存车牌号的成员变量

long total_person;//保存总的载客数的成员变量
double total_weight;//保存总的载重数量的成员变量
};

//类CCar的申明
class CCar: public CVehicle
{
public:
CCar();//构造函数
~CCar();//析构函数

void SetCarriedPerson(long);//设置准载的人数
long GetCarriedPerson(void);//获取准载人数

private:
long carried_person; //保存准载人数
};

class CTruck: public CVehicle
{
public:
CTruck();
~CTruck();

void SetCarriedWeight(double);//设置准载重量
double GetCarriedWeight(void);//获取准载重量

private:
long carried_weight;//保存准载重量的成员变量
};

//类CVehicle的构造函数
CVehicle::CVehicle()
{
p_id = new char[32];//为保存车牌号的成员变量申请32字节内存
p_id[0] = 0;//初始化车牌号为空字符串
total_person = 0;//初始化总的载客数为零个
total_weight = 0;//初始化总的载重吨数为零
};

//类CVehicle的拷贝构造函数
CVehicle::CVehicle(const CVehicle & cv)
{
p_id = new char[32];//为保存车牌号的成员变量申请32字节内存

if (p_id !=NULL )
{
strcpy(p_id,cv.p_id);
total_person = cv.total_person;
total_weight = cv.total_weight;
}
};

//类CVehicle的析构函数
CVehicle::~CVehicle()
{
if (p_id != NULL)
{
delete [] p_id;//释放之前申请的内存
}
};

//设置车牌号的成员函数
void CVehicle::SetCarNo(const char * carno)
{
strcpy(p_id,carno);
};

//获取车牌号的成员函数
const char * CVehicle::GetCarNO(void)
{
return p_id;
};

//设置总的载客数的成员函数
void CVehicle::SetTotalPerson(long tp)
{
total_person = tp;
};

//设置总的载重吨数的成员函数
void CVehicle::SetTotalWeight(double tw)
{
total_weight = tw;
};

//获取总的载客数的成员函数
long CVehicle::GetTotalPerson(void)
{
return total_person;
};

//获取总的载重吨数的成员函数
double CVehicle::GetTotalWeight(void)
{
return total_weight;
};

//重载==运算符
bool CVehicle::operator == (const CVehicle & cv)
{
return (strcmp(cv.p_id,p_id) == 0);
};

//重载!=运算符
bool CVehicle::operator != (const CVehicle & cv)
{
return (strcmp(cv.p_id,p_id) != 0);
};

//类CCar的构造函数
CCar::CCar()
:CVehicle()
{
carried_person = 0;
};

//类CCar的析构函数
CCar::~CCar()
{
//do nothing
};

//类CCar的设置准载人数的成员函数
void CCar::SetCarriedPerson(long cp)
{
carried_person = cp;
SetTotalPerson(cp);
};

//类CCar的获取准载人数的成员函数
long CCar::GetCarriedPerson(void)
{
return carried_person;
};

//类CTruck的构造函数
CTruck::CTruck()
:CVehicle()
{
carried_weight = 0;
};

//类CTruck的析构函数
CTruck::~CTruck()
{
//do nothing
};

//类CTruck的设置准载重量的成员函数
void CTruck::SetCarriedWeight(double cw)
{
carried_weight = cw;
SetTotalWeight(cw);
};

//类CTruck的获取准载重量的成员函数
double CTruck::GetCarriedWeight(void)
{
return carried_weight;
};

//获取车牌号的友员函数
char * GetVehicleID(const CVehicle & cv)
{
return cv.p_id;
};

//在下面编写测试上面定义的类的代码.
//并未写完整,你可以根据你自己的需要添加测试代码.
int main(int argc, char* argv[])
{
CVehicle cv;
cv.SetCarNo("川A5168");
cv.SetTotalPerson(5);
cv.SetTotalWeight(2);

cout<<GetVehicleID(cv)<<endl;

CVehicle cv1(cv);
cout<<(cv1 == cv)<<endl;

cout<<cv1.GetCarNO()<<endl;

return 0;
};

Ⅱ php如何生成自解压文件

php ZipArchive 能否在指定目录生成压缩包

初步接触ZipArchive , 目前发现 ZipArchive类生成的zip压缩包是存储在 ppublic function backupfiles(){ $filename = "backups/". time().".zip"; $zip = new \ZipArchive(); $zip->open($filename,\ZipArchive::CREATE); $path = 'demo';//指定的目录 $this->addFileToZip($path, $zip); } public function addFileT

如何用PHP创建一个加密的zip压缩文件

/* creates a compressed zip file */function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && 。

PHP-php生成zip压缩文件如何给该文件加解压缩密码
php如何压缩一个文件夹里面所有的文件到zip文件里面?

//函数:文件压缩//压缩参数:需要压缩的文件或文件夹(文件可为数组),压缩后的zip文件名及存放路径,压缩类型1:文件夹2:文件,后续操作1:压缩后下载;2:存放在服务器上(默认为/@Upload下)//压缩文件夹示例:Tozip("./","../".date("d-H-i-s").".zip",1

如何在PHP中创建压缩的RAR文件

$filename = "./" . date ( 'YmdH' ) . ".zip"; // 最终生成的文件名(含路径) // 生成文件 $zip = new ZipArchive (); // 使用本类,linux需开启zlib,windows需取消php_zip.dll前的注释 if ($zip->open ( $filename, ZIPARCHIVE::CREATE ) 。

看你的内存是多大了,只要你的虚拟内存和物理内存够大。

怎样用php压缩解压rar,zip文件?

要用PHP压缩解压文件,常用的方法是调用命令行去执行解压缩操作 可以用exec() 、system()等函数调用shell命令 Linux下解压缩命令是tar [-cxtzjvfpPN] 文件与目录,tar命令可以压缩解压.tar、.gz、.tar.gz、.tgz、.bz

请高手指点:PHP 如何解压缩zip格式压缩的文件或压zip格式压缩了几个文件,或压缩了一个文件夹,文件夹里有多个文件, 现/** * PHP在线压缩/解压实例 */ date_default_timezone_set('prc'); $zip = new engine_compress_decompress(); if (isset($_POST)) { $sourcePath = ''; //默认位置 if (isset($_FILES['upfile'])) //上传文件 { $stmp = $zip->fileUpload('upf

以上就是CSS布局HTML为大家整理的php生成zip压缩文件的方法详解 技术分享内容,如果觉得小编的资源对您有帮助 不要忘记分享给您身边的朋友哦!

Ⅲ 大侠们,请问php在线解压rar文档 代码,急需要...........谢谢!

PHP没有处理rar压缩的函数,自己编写也不太现实,我建议在php里面调用rar.exe来压缩和解压缩文件,调用rar.exe的时候参数比较多,可以运行rar.exe /?显示,一般参数格式是:
用法: rar <命令> -<开关 1> -<开关 N> <压缩文件> <文件...>
<@列表文件...> <解压路径\>

<命令>
a 添加文件到压缩文件
c 添加压缩文件注释
cf 添加文件注释
ch 改变压缩文件参数
cw 写入压缩文件注释到文件
d 删除压缩文件中的文件
e 解压压缩文件到当前目录

例如要解压当前文件夹下的a.rar的php语句是:
system('"C:\Program Files (x86)\WinRAR\rar.exe" e .\a.rar');

如果你不是WIN7,或者安装文件夹不同,注意更改文件位置。

Ⅳ (急)php 解压文件(unzip)

1、先下载 http://www.canphp.com/upload/canphp1.4.zip
2、里面有个 canphp\lib\Zip.class.php 文件,仅仅需要这个文件就行了,这是个压缩与解压缩的类,在需要的地方,包含这个文件即可使用。
3、使用方法:
(1)压缩:
$zip=new Zip();
$zip->compress('template.zip','template');//将template目录的所有文件压缩到template.zip文件
(2)解压:
$zip=new Zip();
$zip->decompress('template.zip','template2');//将template.zip压缩文件,解压到template2目录 。
4、两种方法的返回值请参考Zip.class.php 或 var_mp 返回值
5、实际测试成功,只是返回一些notice。我的代码如下:
<?php
require_once "zip.class.php";
$zip = new Zip();
$zip->compress('xtw.zip', 'template');
$zip->decompress('xtw.zip', 'template2');
?>

Ⅳ php 怎把上传的rar zip文件 自动解压 用的是哪个函数 求高手指点 告急 谢谢 求源代码

/**
* PHP在线压缩/解压实例
*/

date_default_timezone_set('prc');

$zip = new engine_compress_decompress();

if (isset($_POST))
{
$sourcePath = ''; //默认位置

if (isset($_FILES['upfile'])) //上传文件
{
$stmp = $zip->fileUpload('upfile');
$sourcePath = $stmp['sourcefile'];
$upfileError = $stmp['error'];
}
elseif (isset($_POST['inputfile'])) //输入目录或者文件
{
$sourcePath = $_POST['inputfile'];
}
elseif (isset($_POST['decompresssourcefiles'])) //解压缩提交
{
$isDecompress = $zip->decompress($_POST['decompresssourcefiles'], $_POST['topath']);
if (!empty($isDecompress['filelist']))
{
$href = '<script type="text/javascript" language="javascript">window.location.href=\'#decompress\'</script>';
}

}

$fileList = $zip->fileArray($sourcePath); //解压缩文件列表

if (isset($_POST['compressinputfileorfolder'])) //压缩文件目录或者文件输入
{
$sourcePath = $_POST['compressinputfileorfolder'];
$href = '<script type="text/javascript" language="javascript">window.location.href=\'#compress\'</script>';
$compressFilelist = $zip->compressFileArray($sourcePath); //压缩文件列表
}
elseif ((isset($_POST['selectcompressfilelist'])) && (isset($_POST['compresssavefilename'])))
{
$compressFiles = $zip->compress($_POST['selectcompressfilelist'], $_POST['compresssavefilename']); //真实检测
$isCompress = $zip->CompileZipFile($compressFiles, $zip->savePath, 'all');
if (!empty($isCompress))
{
$href = '<script type="text/javascript" language="javascript">window.location.href=\'#compress\'</script>';
}
}
}

Ⅵ PHP的解压缩函数怎么用

在你的PHP安装根目录下,找到php.ini并打开,查找;extension=php_zip.dll,将这行指令前面的";"删掉,就表示开启压缩功能。。。
如果你的虚拟空间不能用压缩功能那表示空间服务商没有开启这个功能。

热点内容
滑板鞋脚本视频 发布:2025-02-02 09:48:54 浏览:432
群晖怎么玩安卓模拟器 发布:2025-02-02 09:45:23 浏览:557
三星安卓12彩蛋怎么玩 发布:2025-02-02 09:44:39 浏览:743
电脑显示连接服务器错误 发布:2025-02-02 09:24:10 浏览:537
瑞芯微开发板编译 发布:2025-02-02 09:22:54 浏览:146
linux虚拟机用gcc编译时显示错误 发布:2025-02-02 09:14:01 浏览:235
java驼峰 发布:2025-02-02 09:13:26 浏览:651
魔兽脚本怎么用 发布:2025-02-02 09:10:28 浏览:538
linuxadobe 发布:2025-02-02 09:09:43 浏览:212
sql2000数据库连接 发布:2025-02-02 09:09:43 浏览:726