vfprintf

(PHP 5, PHP 7, PHP 8)

vfprintf將格式化字符串寫入流

說明

vfprintf(resource $handle, string $format, array $args): int

向由 handle 指定的流資源句柄中寫入根據 format 格式化后的字符串。

作用與 fprintf() 函數類似,但是接收一個數組參數,而不是一系列可變數量的參數。

參數

handle

format

關于 format 的描述,參見 sprintf()

args

返回值

返回輸出字符串的長度。

范例

示例 #1 vfprintf(): 前導 0 的整數

<?php
if (!($fp fopen('date.txt''w')))
    return;

vfprintf($fp"%04d-%02d-%02d", array($year$month$day));
// 將向 date.txt 寫入格式化的 ISO 標準日期
?>

參見