file_put_contents() 函數把一個字符串寫入文件中
file_put_contents(file,data,mode,context)
參數 | 描述 |
---|---|
file | 必需。規定要寫入數據的文件。若是文件不存在,則建立一個新文件。 |
data | 可選。規定要寫入文件的數據。能夠是字符串、數組或數據流。 |
mode | 可選。規定如何打開/寫入文件。可能的值:php
|
context | 可選。規定文件句柄的環境。spa context 是一套能夠修改流的行爲的選項。若使用 null,則忽略。orm |
該函數將返回寫入到文件內數據的字節數
<?php $filename = "ceshi/2.txt"; $content = file_get_contents($filename); // highlight_string($content); highlight_file($filename); file_put_contents($filename,$content."xinde"); ?>
dsfsdfsafsdfdsxindexindexinde 34