久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php文件怎么轉(zhuǎn)換成字符串

      php中可利用file_get_contents()函數(shù)來將文件轉(zhuǎn)換成字符串,它可將文件的內(nèi)容讀取到一個(gè)字符串中,語(yǔ)法“file_get_contents(file,include_path,context,start,maxlen)”。

      php文件怎么轉(zhuǎn)換成字符串

      本教程操作環(huán)境:windows7系統(tǒng)、PHP7.1版,DELL G3電腦

      在php中,可以利用file_get_contents()函數(shù)來將文件轉(zhuǎn)換成字符串。

      file_get_contents() 函數(shù)可以將文件的內(nèi)容讀取到一個(gè)字符串中,函數(shù)的語(yǔ)法格式如下:

      file_get_contents(file,include_path,context,start,maxlen)

      參數(shù)說明如下:

      • file:要讀取的文件;
      • include_path:可選參數(shù),用來設(shè)定是否想要在 include_path 中搜索該文件,默認(rèn)為 FALSE;
      • context:可選參數(shù),用來表示使用 stream_context_create() 函數(shù)創(chuàng)建的有效的上下文資源,如果不需要自定義 context,可以用 NULL 來忽略;
      • start:可選參數(shù),用來設(shè)定文件中開始讀取的位置。注意,不能對(duì)遠(yuǎn)程文件使用該參數(shù);
      • maxlen:可選參數(shù),用來設(shè)定讀取的字節(jié)數(shù),默認(rèn)是讀取文件的全部?jī)?nèi)容。

      注意:file_get_contents() 函數(shù)執(zhí)行失敗時(shí),可能返回 Boolean 類型的 FALSE,也可能返回一個(gè)非布爾值(如空字符)。所以一般使用===運(yùn)算符測(cè)試此函數(shù)的返回值。

      示例:

      有這么一個(gè)文本文件,內(nèi)容為:

      php文件怎么轉(zhuǎn)換成字符串

      使用file_get_contents()函數(shù)將該文件轉(zhuǎn)換成字符串

      <?php header("Content-type:text/html;charset=utf-8"); $file = 'test.txt'; $filestr = file_get_contents($file); if ($filestr) { 	echo $filestr; } else { 	echo '失??!'; } ?>

      輸出結(jié)果:

      php文件怎么轉(zhuǎn)換成字符串

      推薦學(xué)習(xí):php培訓(xùn)

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)