无需言 做自己 业 ,精于勤 荒于嬉.
- 文件系统函数 tempnam 建立一个具有唯一文件名的文件
-
发表日期:2021-07-01 08:55:45 | 来源: | 分类:文件系统函数
-
示例1
<?php $tmpfname = tempnam("/tmp", "FOO"); $handle = fopen($tmpfname, "w"); fwrite($handle, "writing to tempfile"); fclose($handle); // do here something unlink($tmpfname); ?>
- 文件系统函数 symlink 建立符号连接
-
发表日期:2021-07-01 08:55:45 | 来源: | 分类:文件系统函数
-
示例1
<?php $target = 'uploads.php'; $link = 'uploads'; symlink($target, $link); echo readlink($link); ?>
- 文件系统函数 umask 改变当前的 umask
-
发表日期:2021-07-01 08:55:45 | 来源: | 分类:文件系统函数
-
示例1
<?php $old = umask(0); chmod("/path/some_dir/some_file.txt", 0755); umask($old); // Checking if ($old != umask()) { die('An error occured while changing back the umask'); } ?>
- iconv 函数 iconv_get_encoding 获取 iconv 扩展的内部配置变量
-
发表日期:2021-07-01 08:55:45 | 来源: | 分类:iconv 函数
-
示例1
<?php iconv_set_encoding("internal_encoding", "UTF-8"); iconv_set_encoding("output_encoding", "ISO-8859-1"); var_dump(iconv_get_encoding('all')); </pre>
- iconv 函数 iconv_mime_decode_headers 一次性解码多个 MIME 头字段
-
发表日期:2021-07-01 08:55:45 | 来源: | 分类:iconv 函数
-
示例1
<?php $headers_string = <<<EOFSubject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=To: example@example.comDate: Thu, 1 Jan 1970 00:00:00 +0000Message-Id: <example@example.com>Received: from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000EOF; $headers = iconv_mime_decode_headers($headers_string, 0, "ISO-8859-1"); print_r($headers); ?>
- 文件系统函数 lchgrp 修改符号链接的所有组
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $target = 'output.php'; $link = 'output.html'; symlink($target, $link); lchgrp($link, 8); ?>
- 文件系统函数 is_uploaded_file 判断文件是否是通过 HTTP POST 上传的
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { echo "File ". $_FILES['userfile']['name'] ." uploaded successfully.\n"; echo "Displaying contents\n"; readfile($_FILES['userfile']['tmp_name']); } else { echo "Possible file upload attack: "; echo "filename '". $_FILES['userfile']['tmp_name'] . "'."; } ?>
- 文件系统函数 is_writable 判断给定的文件名是否可写
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $filename = 'test.txt'; if (is_writable($filename)) { echo 'The file is writable'; } else { echo 'The file is not writable'; } ?>
- 文件系统函数 is_writeable is_writable() 的别名
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
说明
此函数是该函数的别名:is_writable()。
- 文件系统函数 lstat 给出一个文件或符号连接的信息
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php symlink('uploads.php', 'uploads'); // Contrast information for uploads.php and uploads array_diff(stat('uploads'), lstat('uploads')); ?>
- 文件系统函数 link 建立一个硬连接
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $target = 'source.ext'; // This is the file that already exists$link = 'newfile.ext'; // This the filename that you want to link it tolink($target, $link); ?>
- 文件系统函数 lchown 修改符号链接的所有者
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $target = 'output.php'; $link = 'output.html'; symlink($target, $link); lchown($link, 8); ?>
- 文件系统函数 mkdir 新建目录
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php mkdir("/path/to/my/dir", 0700); ?>示例2
<?php // Desired folder structure $structure = './depth1/depth2/depth3/'; // To create the nested structure, the $recursive parameter // to mkdir() must be specified. if (!mkdir($structure, 0777, true)) { die('Failed to create folders...'); } // ...?>
- 文件系统函数 move_uploaded_file 将上传的文件移动到新位置
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $uploads_dir = '/uploads'; foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; move_uploaded_file($tmp_name, "$uploads_dir/$name"); } } ?>
- 文件系统函数 parse_ini_string 解析配置字符串
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
parse_ini_string
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
parse_ini_string — 解析配置字符串
说明
parse_ini_string(string$ini, bool$process_sections= false, int$scanner_mode= INI_SCANNER_NORMAL): arrayparse_ini_string() 返回
ini字符串解析后的关联数组ini 字符串的格式参考 php.ini
参数
-
ini -
ini 字符串内容
-
process_sections -
设置
process_sections参数为true,得到一个多维数组,包含名称和设置。process_sections默认为false -
scanner_mode -
可以是
INI_SCANNER_NORMAL(默认)或INI_SCANNER_RAW。如果是INI_SCANNER_RAW,那么选项值不会被解析。As of PHP 5.6.1 can also be specified as
INI_SCANNER_TYPED. In this mode boolean, null and integer types are preserved when possible. String values"true","on"and"yes"are converted totrue."false","off","no"and"none"are consideredfalse."null"is converted tonullin typed mode. Also, all numeric strings are converted to integer type if it is possible.
返回值
执行成功返回一个关联数组,返回
false为失败注释
注意: 保留关键字不能作为 ini 的键,包括 null, yes, no, true, false, on, off, none以及空值,off,no 和错误的结果集,值为 yes 和 正确的结果集。除非使用
INI_SCANNER_TYPED模式。 字符?{}|&~![()^"不能在任何地方使用作为键和有特殊意义的值。 -
- 文件系统函数 parse_ini_file 解析一个配置文件
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php define('BIRD', 'Dodo bird'); // Parse without sections $ini_array = parse_ini_file("sample.ini"); print_r($ini_array); // Parse with sections $ini_array = parse_ini_file("sample.ini", true); print_r($ini_array); ?>示例2
<?php // A simple function used for comparing the results below function yesno($expression){ return($expression ? 'Yes' : 'No'); } // Get the path to php.ini using the php_ini_loaded_file() // function available as of PHP 5.2.4 $ini_path = php_ini_loaded_file(); // Parse php.ini $ini = parse_ini_file($ini_path); // Print and compare the values, note that using get_cfg_var() // will give the same results for parsed and loaded here echo '(parsed) magic_quotes_gpc = ' . yesno($ini['magic_quotes_gpc']) . PHP_EOL; echo '(loaded) magic_quotes_gpc = ' . yesno(get_cfg_var('magic_quotes_gpc')) . PHP_EOL; ?>
- 文件系统函数 pclose 关闭进程文件指针
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $handle = popen('/bin/ls', 'r'); pclose($handle); ?>
- 文件系统函数 pathinfo 返回文件路径的信息
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $path_parts = pathinfo('/www/htdocs/inc/lib.inc.php'); echo $path_parts['dirname'], "\n"; echo $path_parts['basename'], "\n"; echo $path_parts['extension'], "\n"; echo $path_parts['filename'], "\n"; // since PHP 5.2.0?>示例2
<?php $path_parts = pathinfo('/path/emptyextension.'); var_dump($path_parts['extension']); $path_parts = pathinfo('/path/noextension'); var_dump($path_parts['extension']); ?>
- 文件系统函数 readfile 输出文件
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php $file = 'monkey.gif'; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } ?>
- 文件系统函数 realpath_cache_get 获取真实目录缓存的详情
-
发表日期:2021-07-01 08:55:44 | 来源: | 分类:文件系统函数
-
示例1
<?php var_dump(realpath_cache_get()); ?>
- 前端开发(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号