最新亚洲精品福利在线,欧美一区二区三区大片,久久91无码一区二区三区,色哟哟免费观看视频入口,美女裸露双奶头屁股无裸体

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

時(shí)間:2017-05-06 22:30:16 類(lèi)型:PHP
字號(hào):    

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


$myfile = fopen("./tmp/token.php", "w"); 
//文件存在,就打開(kāi),不存在就在當(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)容寫(xiě)入到 token.php文件
fclose($myfile);
生成的結(jié)果如下:



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