(PHP 5 >= 5.1.0, PHP 7, PHP 8)
posix_mknod — 创建特殊文件或普通文件 (POSIX.1)
filename要创建的文件
flags此参数由文件类型(以下常量之一:POSIX_S_IFREG、POSIX_S_IFCHR、POSIX_S_IFBLK、POSIX_S_IFIFO 或 POSIX_S_IFSOCK)和权限按位或运算构成。
major主要设备内核标识符(使用 S_IFCHR 或 S_IFBLK 时需要传递)。
minor次要设备内核标识符。
示例 #1 posix_mknod() 示例
<?php
$file = '/tmp/tmpfile'; // 文件名
$type = POSIX_S_IFBLK; // 文件类型
$permissions = 0777; // 八进制
$major = 1;
$minor = 8; // /dev/random
if (!posix_mknod($file, $type | $permissions, $major, $minor)) {
die('错误 ' . posix_get_last_error() . ': ' . posix_strerror(posix_get_last_error()));
}
?>