无需言 做自己 业 ,精于勤 荒于嬉.
- 文件系统函数 fclose 关闭一个已打开的文件指针
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php $handle = fopen('somefile.txt', 'r'); fclose($handle); ?>
- 文件系统函数 diskfreespace disk_free_space() 的别名
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
说明
此函数是该函数的别名:disk_free_space()。
- 文件系统函数 feof 测试文件指针是否到了文件结束的位置
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php function safe_feof($fp, &$start = NULL) { $start = microtime(true); return feof($fp); } /* $fp 的赋值是由之前 fsockopen() 打开 */ $start = NULL; $timeout = ini_get('default_socket_timeout'); while(!safe_feof($fp, $start) && (microtime(true) - $start) < $timeout){ /* Handle */ } ?>示例2
<?php // 如果文件不可读取或者不存在,fopen 函数返回 FALSE$file = @fopen("no_such_file", "r"); // 来自 fopen 的 FALSE 会发出一条警告信息并在这里陷入无限循环while (!feof($file)) { } fclose($file); ?>
- 文件系统函数 fgetc 从文件指针中读取字符
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php $fp = fopen('somefile.txt', 'r'); if (!$fp) { echo 'Could not open file somefile.txt'; } while (false !== ($char = fgetc($fp))) { echo "$char\n"; } ?>
- 文件系统函数 chmod 改变文件模式
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php chmod("/somedir/somefile", 755); // 十进制数,可能不对chmod("/somedir/somefile", "u+rwx,go+rx"); // 字符串,不对chmod("/somedir/somefile", 0755); // 八进制数,正确的 mode 值?>示例2
<?php // Read and write for owner, nothing for everybody elsechmod("/somedir/somefile", 0600); // Read and write for owner, read for everybody elsechmod("/somedir/somefile", 0644); // Everything for owner, read and execute for otherschmod("/somedir/somefile", 0755); // Everything for owner, read and execute for owner's groupchmod("/somedir/somefile", 0750); ?>
- 文件系统函数 fgets 从文件指针中读取一行
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php $handle = @fopen("/tmp/inputfile.txt", "r"); if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { echo $buffer; } if (!feof($handle)) { echo "Error: unexpected fgets() fail\n"; } fclose($handle); } ?>
- 文件系统函数 fgetss 从文件指针中读取一行并过滤掉 HTML 标记
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php $str = <<<EOD<html><body> <p>Welcome! Today is the <?php echo(date('jS')); ?> of <?= date('F'); ?>.</p></body></html>Text outside of the HTML block.EOD; file_put_contents('sample.php', $str); $handle = @fopen("sample.php", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgetss($handle, 4096); echo $buffer; } fclose($handle); } ?>
- 文件系统函数 file_exists 检查文件或目录是否存在
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?>
- 文件系统函数 file_put_contents 将一个字符串写入文件
-
发表日期:2021-07-01 08:55:41 | 来源: | 分类:文件系统函数
-
示例1
<?php $file = 'people.txt'; // Open the file to get existing content $current = file_get_contents($file); // Append a new person to the file $current .= "John Smith\n"; // Write the contents back to the file file_put_contents($file, $current); ?>
示例2
<?php $file = 'people.txt'; // The new person to add to the file $person = "John Smith\n"; // Write the contents to the file, // using the FILE_APPEND flag to append the content to the end of the file // and the LOCK_EX flag to prevent anyone else writing to the file at the same time file_put_contents($file, $person, FILE_APPEND | LOCK_EX); ?>
- 文件系统函数 chgrp 改变文件所属的组
-
发表日期:2021-07-01 08:55:40 | 来源: | 分类:文件系统函数
-
示例1
<?php $filename = 'shared_file.txt'; $format = "%s's Group ID @ %s: %d\n"; printf($format, $filename, date('r'), filegroup($filename)); chgrp($filename, 8); clearstatcache(); // do not cache filegroup() resultsprintf($format, $filename, date('r'), filegroup($filename)); ?>
- 文件系统函数 copy 拷贝文件
-
发表日期:2021-07-01 08:55:40 | 来源: | 分类:文件系统函数
-
示例1
<?php $file = 'example.txt'; $newfile = 'example.txt.bak'; if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?>
- 文件系统函数 clearstatcache 清除文件状态缓存
-
发表日期:2021-07-01 08:55:40 | 来源: | 分类:文件系统函数
-
示例1
<?php $file = 'output_log.txt'; function get_owner($file){ $stat = stat($file); $user = posix_getpwuid($stat['uid']); return $user['name']; } $format = "UID @ %s: %s\n"; printf($format, date('r'), get_owner($file)); chown($file, 'ross'); printf($format, date('r'), get_owner($file)); clearstatcache(); printf($format, date('r'), get_owner($file)); ?>
- Fileinfo 函数 finfo_filefinfo::file 返回一个文件的信息
-
发表日期:2021-07-01 08:55:36 | 来源: | 分类:Fileinfo 函数
-
示例1
<?php $finfo = finfo_open(FILEINFO_MIME_TYPE); // 返回 mime 类型 foreach (glob("*") as $filename) { echo finfo_file($finfo, $filename) . "\n"; } finfo_close($finfo); ?>
- Fileinfo 函数 finfo_close 关闭 fileinfo 资源
-
发表日期:2021-07-01 08:55:36 | 来源: | 分类:Fileinfo 函数
-
finfo_close
(PHP >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0)
finfo_close — 关闭 fileinfo 资源
返回值
成功时返回
true, 或者在失败时返回false。
- Fileinfo 函数 finfo_bufferfinfo::buffer 返回一个字符串缓冲区的信息
-
发表日期:2021-07-01 08:55:35 | 来源: | 分类:Fileinfo 函数
-
示例1
<?php $finfo = new finfo(FILEINFO_MIME); echo $finfo->buffer($_POST["script"]) . "\n"; ?>
- Fileinfo 函数 finfo_set_flagsfinfo::set_flags 设置 libmagic 配置选项
-
发表日期:2021-07-01 08:55:35 | 来源: | 分类:Fileinfo 函数
-
finfo_set_flags
finfo::set_flags
(PHP >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0)
finfo_set_flags -- finfo::set_flags — 设置 libmagic 配置选项
说明
过程化风格
finfo_set_flags(resource$finfo, int$options): bool面向对象风格
public finfo::set_flags(int$options): bool此函数用来设置 Fileinfo 选项。 这些选项也可以在调用 finfo_open() 或者其他 Fileinfo 函数时直接指定。
返回值
成功时返回
true, 或者在失败时返回false。
- Fileinfo 函数 finfo_openfinfo::__construct 创建一个 fileinfo 资源
-
发表日期:2021-07-01 08:55:35 | 来源: | 分类:Fileinfo 函数
-
示例1
<?php $finfo = new finfo(FILEINFO_MIME, "/usr/share/misc/magic"); // 返回 mime 类型/* get mime-type for a specific file */ $filename = "/usr/local/something.txt"; echo $finfo->file($filename); ?>
示例2
<?php $finfo = finfo_open(FILEINFO_MIME, "/usr/share/misc/magic"); // 返回 mime 类型 if (!$finfo) { echo "Opening fileinfo database failed"; exit(); } /* 获取指定文件的 mime 类型 */ $filename = "/usr/local/something.txt"; echo finfo_file($finfo, $filename); /* 关闭资源 */ finfo_close($finfo); ?>
- Fileinfo 函数 mime_content_type 检测文件的 MIME 类型
-
发表日期:2021-07-01 08:55:35 | 来源: | 分类:Fileinfo 函数
-
示例1
<?php echo mime_content_type('php.gif') . "\n"; echo mime_content_type('test.php'); ?>
- 目录函数 closedir 关闭目录句柄
-
发表日期:2021-07-01 08:55:31 | 来源: | 分类:目录函数
-
示例1
<?php $dir = "/etc/php5/"; // Open a known directory, read directory into variable and then close if (is_dir($dir)) { if ($dh = opendir($dir)) { $directory = readdir($dh); closedir($dh); } } ?>
- 目录函数 dir 返回一个 Directory 类实例
-
发表日期:2021-07-01 08:55:31 | 来源: | 分类:目录函数
-
示例1
<?php $d = dir("/etc/php5"); echo "Handle: " . $d->handle . "\n"; echo "Path: " . $d->path . "\n"; while (false !== ($entry = $d->read())) { echo $entry."\n"; } $d->close(); ?>
- 前端开发(1)
- 数据库(0)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号