无需言 做自己 业 ,精于勤 荒于嬉.
- 文件系统函数 realpath_cache_size 获取真实路径缓冲区的大小
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php var_dump(realpath_cache_size()); ?>
- 文件系统函数 readlink 返回符号连接指向的目标
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php // output e.g. /boot/vmlinux-2.4.20-xfs echo readlink('/vmlinuz'); ?>
- 文件系统函数 fpassthru 输出文件指针处的所有剩余数据
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php // 以二进制格式打开文件 $name = './img/ok.png'; $fp = fopen($name, 'rb'); // 发送合适的报头 header("Content-Type: image/png"); header("Content-Length: " . filesize($name)); // 发送图片并终止脚本 fpassthru($fp); exit; ?>
- 文件系统函数 fputs fwrite() 的别名
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
- 文件系统函数 fscanf 从文件中格式化输入
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php $handle = fopen("users.txt", "r"); while ($userinfo = fscanf($handle, "%s\t%s\t%s\n")) { list ($name, $profession, $countrycode) = $userinfo; //... do something with the values} fclose($handle); ?>示例2
javier argonaut pe hiroshi sculptor jp robert slacker us luigi florist it
- 文件系统函数 fread 读取文件(可安全用于二进制文件)
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php // get contents of a file into a string$filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); ?>
示例2
<?php $filename = "c:\\files\\somepic.gif"; $handle = fopen($filename, "rb"); $contents = fread($handle, filesize($filename)); fclose($handle); ?>
示例3
<?php // 对 PHP 5 及更高版本 $handle = fopen("http://www.example.com/", "rb"); $contents = stream_get_contents($handle); fclose($handle); ?>示例4
<?php $handle = fopen("http://www.example.com/", "rb"); $contents = ''; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); ?>
- 文件系统函数 fseek 在文件指针中定位
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php $fp = fopen('somefile.txt', 'r'); // read some data $data = fgets($fp, 4096); // move back to the beginning of the file // same as rewind($fp); fseek($fp, 0); ?>
- 文件系统函数 ftruncate 将文件截断到给定的长度
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php $filename = 'lorem_ipsum.txt'; $handle = fopen($filename, 'r+'); ftruncate($handle, rand(1, filesize($filename))); rewind($handle); echo fread($handle, filesize($filename)); fclose($handle); ?>
- 文件系统函数 fstat 通过已打开的文件指针取得文件信息
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php // 打开文件 $fp = fopen("/etc/passwd", "r"); // 取得统计信息 $fstat = fstat($fp); // 关闭文件 fclose($fp); // 只显示关联数组部分 print_r(array_slice($fstat, 13)); ?>
- 文件系统函数 fgetcsv 从文件指针中读入一行并解析 CSV 字段
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } ?>
- 文件系统函数 is_dir 判断给定文件名是否是一个目录
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php var_dump(is_dir('a_file.txt')); var_dump(is_dir('bogus_dir/abc')); var_dump(is_dir('..')); //one dir up?>
- 文件系统函数 ftell 返回文件指针读/写的位置
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php // opens a file and read some data$fp = fopen("/etc/passwd", "r"); $data = fgets($fp, 12); // where are we ?echo ftell($fp); // 11fclose($fp); ?>
- 文件系统函数 fwrite 写入文件(可安全用于二进制文件)
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php function fwrite_stream($fp, $string) { for ($written = 0; $written < strlen($string); $written += $fwrite) { $fwrite = fwrite($fp, substr($string, $written)); if ($fwrite === false) { return $written; } } return $written; } ?>示例2
<?php $fp = fopen('data.txt', 'w'); fwrite($fp, '1'); fwrite($fp, '23'); fclose($fp); // the content of 'data.txt' is now 123 and not 23!?>示例3
<?php $filename = 'test.txt'; $somecontent = "添加这些文字到文件\n"; // 首先我们要确定文件存在并且可写。 if (is_writable($filename)) { // 在这个例子里,我们将使用添加模式打开 $filename, // 因此,文件指针将会在文件的末尾, // 那就是当我们使用fwrite()的时候,$somecontent将要写入的地方。 if (!$handle = fopen($filename, 'a')) { echo "不能打开文件 $filename"; exit; } // 将$somecontent写入到我们打开的文件中。 if (fwrite($handle, $somecontent) === FALSE) { echo "不能写入到文件 $filename"; exit; } echo "成功地将 $somecontent 写入到文件$filename"; fclose($handle); } else { echo "文件 $filename 不可写"; } ?>
- 文件系统函数 glob 寻找与模式匹配的文件路径
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php foreach (glob("*.txt") as $filename) { echo "$filename size " . filesize($filename) . "\n"; } ?>
- 文件系统函数 is_executable 判断给定文件名是否可执行
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php $file = '/home/vincent/somefile.sh'; if (is_executable($file)) { echo $file.' is executable'; } else { echo $file.' is not executable'; } ?>
- 文件系统函数 is_readable 判断给定文件名是否可读
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php $filename = 'test.txt'; if (is_readable($filename)) { echo 'The file is readable'; } else { echo 'The file is not readable'; } ?>
- 文件系统函数 is_file 判断给定文件名是否为一个正常的文件
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php var_dump(is_file('a_file.txt')) . "\n"; var_dump(is_file('/usr/bin/')) . "\n"; ?>
- 文件系统函数 is_link 判断给定文件名是否为一个符号连接
-
发表日期:2021-07-01 08:55:43 | 来源: | 分类:文件系统函数
-
示例1
<?php $link = 'uploads'; if (is_link($link)) { echo(readlink($link)); } else { symlink('uploads.php', $link); } ?>
- 文件系统函数 file_get_contents 将整个文件读入一个字符串
-
发表日期:2021-07-01 08:55:42 | 来源: | 分类:文件系统函数
-
示例1
<?php $homepage = file_get_contents('http://www.example.com/'); echo $homepage; ?>示例2
<?php // 如果开启了严格类型,例如 declare(strict_types=1); $file = file_get_contents('./people.txt', true); // 否则就这样写$file = file_get_contents('./people.txt', FILE_USE_INCLUDE_PATH); ?>示例3
<?php // 从第 21 个字符开始,读取 14 字符长度$section = file_get_contents('./people.txt', FALSE, NULL, 20, 14); var_dump($section); ?>示例4
<?php // 创建 stream $opts = array('http'=>array('method'=>"GET",'header'=>"Accept-language: en\r\n" ."Cookie: foo=bar\r\n")); $context = stream_context_create($opts); // 以下面设置的 HTTP 头来打开文件 $file = file_get_contents('http://www.example.com/', false, $context); ?>
- 文件系统函数 fileatime 取得文件的上次访问时间
-
发表日期:2021-07-01 08:55:42 | 来源: | 分类:文件系统函数
-
示例1
<?php // 输出类似:somefile.txt was last accessed: December 29 2002 22:16:23. $filename = 'somefile.txt'; if (file_exists($filename)) { echo "$filename was last accessed: " . date("F d Y H:i:s.", fileatime($filename)); } ?>
- 前端开发(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号