PHP fwrite() 函數(shù)
PHP fwrite() 函數(shù)

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

相關(guān)文章
- PHP 變量
- PHP 函數(shù)
- PHP 面向?qū)ο?/a>
- PHP 過(guò)濾器
- PHP JSON
- PHP array() 函數(shù)
- PHP array_diff_key() 函數(shù)
- PHP array_diff_uassoc() 函數(shù)
- PHP array_intersect_key() 函數(shù)
- PHP array_intersect_ukey() 函數(shù)
- PHP array_rand() 函數(shù)
- PHP array_reduce() 函數(shù)
- PHP array_walk() 函數(shù)
- PHP compact() 函數(shù)
- PHP count() 函數(shù)
- PHP in_array() 函數(shù)
- PHP ksort() 函數(shù)
- PHP 5 Calendar 函數(shù)
- PHP cURL 函數(shù)
- PHP 5 Filesystem 函數(shù)