亚洲一级免费看,特黄特色大片免费观看播放器,777毛片,久久久久国产一区二区三区四区,欧美三级一区二区,国产精品一区二区久久久久,人人澡人人草

php語言

php的file-put-contents()功能函數(shù)

時間:2025-01-07 21:24:51 php語言 我要投稿
  • 相關(guān)推薦

php的file-put-contents()功能函數(shù)

  php file_put_contents()功能函數(shù)(集成了fopen、fwrite、fclose) ,需要的朋友可以參考下。就跟隨百分網(wǎng)小編一起去了解下吧,想了解更多相關(guān)信息請持續(xù)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!

  命令:file_put_contents();

  命令解析:file_put_contents (PHP 5)

  file_put_contents -- 將一個字符串寫入文件

  說明:

  int file_put_contents ( string filename, string data [, int flags [, resource context]] )

  和依次調(diào)用 fopen(),fwrite() 以及 fclose() 功能一樣。

  參數(shù) data 可以是數(shù)組(但不能為多維數(shù)組),這就相當(dāng)于 file_put_contents($filename, join('', $array))

  自 PHP 5.1.0 起,data 參數(shù)也可以被指定為 stream 資源,這里 stream 中所保存的緩存數(shù)據(jù)將被寫入到指定文件中,這種用法就相似于使用 stream_copy_to_stream() 函數(shù)。

  參數(shù)

  filename

  要被寫入數(shù)據(jù)的文件名。

  data

  要寫入的數(shù)據(jù)。類型可以是 string,array 或者是 stream 資源(如上面所說的那樣)。

  flags

  flags 可以是 FILE_USE_INCLUDE_PATH,F(xiàn)ILE_APPEND 和/或 LOCK_EX(獲得一個獨(dú)占鎖定),然而使用 FILE_USE_INCLUDE_PATH 時要特別謹(jǐn)慎。

  context

  一個 context 資源。

  寫入代碼(代碼本身無錯,但陰差陽錯學(xué)會了它的另一個功能):

  復(fù)制代碼 代碼如下:

  <?php

  $contents = "這是使用file_put_contents寫入的內(nèi)容";

  $contents2 = array("這是使用","file_put_contents","命令寫入的內(nèi)容");

  file_put_contents("html/caceh.txt",$contents);

  file_put_contents("html/cache2.txt",$contents2);

  ?>

  代碼分析:打算使用file_put_contents命令向cache.txt,cache2.txt這兩個文件中寫入字符串。

  結(jié)果:在html文件目錄內(nèi)新增了caceh.txt文件,你懂了吧————

  謹(jǐn)記:file_put_contents()函數(shù)集成了fopen(),fwrite(),fclose()三種函數(shù),此例中新建的文件就是fopen()的功能.

【php的file-put-contents()功能函數(shù)】相關(guān)文章:

php使用ftp函數(shù)實(shí)現(xiàn)簡單上傳功能02-07

php數(shù)學(xué)常用函數(shù)04-19

PHP數(shù)據(jù)過濾函數(shù)01-26

PHP類與構(gòu)造函數(shù)07-01

PHP常用函數(shù)匯總05-22

PHP常用函數(shù)總結(jié)03-10

PHP函數(shù)知識總結(jié)04-24

PHP基本函數(shù)介紹02-07

php常用的系統(tǒng)函數(shù)05-05