(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
)與權限之間的位元 OR 運算構成。
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()));
}
?>