PHP fputs() 函數(shù)
PHP fputs() 函數(shù)

定義和用法
fputs() 函數(shù)將內(nèi)容寫入一個打開的文件中。
函數(shù)會在到達指定長度或讀到文件末尾(EOF)時(以先到者為準),停止運行。
如果函數(shù)成功執(zhí)行,則返回寫入的字節(jié)數(shù)。如果失敗,則返回 FALSE。
fputs() 函數(shù)是 fwrite() 函數(shù)的別名。
語法
fputs(file,string,length)
參數(shù) | 描述 |
---|---|
file | 必需。規(guī)定要寫入的打開文件。 |
string | 必需。規(guī)定要寫入打開文件的字符串。 |
length | 可選。規(guī)定要寫入的最大字節(jié)數(shù)。 |
提示和注釋
提示:該函數(shù)是二進制安全的。(意思是二進制數(shù)據(jù)(如圖像)和字符數(shù)據(jù)都可以使用此函數(shù)寫入。)
實例
<?php
$file = fopen("test.txt","w");
echo fputs($file,"Hello World. Testing!");
fclose($file);
?>
$file = fopen("test.txt","w");
echo fputs($file,"Hello World. Testing!");
fclose($file);
?>
上面的代碼將輸出:
21

相關(guān)文章
- PHP 語法
- PHP Switch 語句
- PHP 數(shù)組排序
- PHP While 循環(huán)
- PHP 面向?qū)ο?/a>
- PHP $_POST 變量
- PHP 包含文件 include 和 require 語句
- PHP array_combine() 函數(shù)
- PHP array_diff_ukey() 函數(shù)
- PHP array_fill_keys() 函數(shù)
- PHP array_intersect_key() 函數(shù)
- PHP array_intersect_uassoc() 函數(shù)
- PHP array_key_first() 函數(shù)
- PHP natsort() 函數(shù)
- PHP usort() 函數(shù)
- PHP 5 Array 函數(shù)
- PHP 5 Calendar 函數(shù)
- PHP cURL 函數(shù)
- PHP HTTP 函數(shù)
- PHP 雜項 函數(shù)