php fwrite函数的用法是什么

avatar
作者
猴君
阅读量:0

fwrite函数用于向一个打开的文件中写入数据。其基本语法如下:

fwrite ( resource $handle , string $string [, int $length ] ) : int 

参数说明:

  • $handle:文件资源句柄,通过fopen函数打开文件后返回的资源句柄。
  • $string:要写入文件的数据。
  • $length:可选参数,指定要写入的最大字节数。如果未指定,则会将整个$string写入文件。

示例:

$file = fopen("example.txt", "w"); $data = "Hello, World!"; fwrite($file, $data); fclose($file); 

上面的示例将字符串"Hello, World!"写入了名为example.txt的文件中。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!