久久久久久AV无码免费看大片,亚洲一区精品人人爽人人躁,国产成人片无码免费爱线观看,亚洲AV成人无码精品网站,为什么晚上搞的时候要盖被子

php創(chuàng)建文件并寫入php數(shù)組信息

時間:2017-05-06 22:30:16 類型:PHP
字號:    

在php中, 我們一般都是把數(shù)組存儲在數(shù)據(jù)庫中,  但有時也會對不經(jīng)常更新的數(shù)據(jù)存儲到文件中, 這樣在讀取信息時會比從數(shù)據(jù)庫中更快,  實例方法如下:


$myfile = fopen("./tmp/token.php", "w"); 
//文件存在,就打開,不存在就在當(dāng)前目錄的tmp目錄下創(chuàng)建token.php件
$txt = "<?php\n";
$txt .= "	return array(\n";
$txt .= "          'names'=>'莊子',\n" ;
$txt .= "          'sex'  =>'男',  \n" ;
$txt .= "          'age'  => 18   \n" ;
$txt .= "	);\n";
$txt .= "?>\n";
fwrite($myfile, $txt); 
//將 $txt 內(nèi)容寫入到 token.php文件
fclose($myfile);
生成的結(jié)果如下:



return array(
          'names'=>'莊子',
          'sex'  =>'男',  
          'age'  => 18   
	);