PHP 文件操作

10 篇文章 0 订阅

 

 

file_exists, to check whether the file exists

is_file, to check the file is indeed a file and not a directory

is_readable, to check whether the file can be read

is_writable to check whether the file can be written to

filemtime to check the date and time at which the file the file was last modified

fileatime to find the date and time the file at which was last accessed

filesize to check the file’s size

 

 

 

获取文件大小 php

 

 

 

 

 

 

 

1.file() 把整个文件读入一个数组中,数组中的每个单元都是文件中相应的一行,包括换行符在内

eg: file('http://www.dianzhui.net/index.html')

2.file_get_contents() 将整个文件读入一个字符串

3.readfile() 读入一个文件并写入到输出缓冲

4.fopen('file','rb'); fread($fp,filesize('file'));  feof($fp)测试文件指针是否到了文件结束的位置 fgetc($fg)从文件指针中读取字符          fgets($handle[,int $length ])从文件指针中读取一行

   fopen ( string $filename , string $mode [, bool $use_include_path [, resource $zcontext ]] )打开文件或者 URL

   fread( int $handle , int $length ) 读取文件(可安全用于二进制文件)

 

 

 

PHP检测目录

1. opendir() readdir() rewinddir() closedir()

opendir( string $path [, resource $context ] )  打开目录句柄

readdir( resource $dir_handle ) 从目录句柄中读取条目

closedir()

rewinddir() — 倒回目录句柄

eg:

 

 

2.dir — directory 类

    dir::dir ( string $directory )

    string $path ;

resource $handle ;

string read ( void )

void rewind ( void )

void close ( void )

eg:

 

 

 

 

PHP显示屏和平代码

highlight_file ( string $filename [, bool $return = false ] ) 当bool 为true 时,返回字符串,并不是显示

highlight_string(string $str [, bool $return = false ] ) 当bool 为true 时,返回字符串,并不是显示

parse_ini_file( string $filename [, bool $process_sections ] ) — 解析一个配置文件

 

php管理文件下载 『通过特殊的HTTP头和readfile函数』

创建ZIP/TAR文件 用 『pear』类 Archive_Tar 

参考:

http://pear.php.net/package/Archive_Tar/docs/latest/Archive_Tar/Archive_Tar.html

http://pear.php.net/package/Archive_Tar/download/1.3.7/

eg:

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值