php中配置檔案儲存修改操作 如config.php檔案的讀取修改等操作
阿新 • • 發佈:2021-05-13
f程式設計客棧puts() 定義和用法
fputs() 函式寫入檔案(可安全用於二進位制檔案)。
fputhttp://www.cppcns.coms() 函式是 fwrite() 函式的別名。
//file 必需。規定要寫入的開啟檔案。
//string 必需。規定要寫入檔案的字串。
//length 可選。規定要寫入的最大位元組數。
fputs(file,string,length)
<?php $file = fopen("test.txt","w"); echo fputs($file,"Hello World. Testing!"); fclose($file); ?>
如config.php檔案http://www.cppcns.com的讀取修改等操作
if($request->isPost()){ $data = $request->param(); $newdata = <<<php <?php //七牛雲外掛配置 return [ 'accessKey' => '{$data['accessKey']}','secretKey' => '{$data['secretKey']}','bucket' => '{$data['bucket']}','domain' => '{$data['domain']}' ]; php; @chmod(ADDON_PATH.'qiniu/config.php',0777);//給檔案許可權 $fop=fopen(ADDhttp://www.cppcns.comON_PATH.'qiniu/config.php','w');//開啟檔案 $res = fputs($fop,$newdata);//寫入檔案 fclose($fop);//關閉檔案 if($res){//檔案寫入成功返回狀態 return json(['code'=>1,'msg'=>'修改成功!']); }else{ return json(['code'=>0,'msg'=>'修改失敗!']); } }
到此這篇關於php中配置檔案儲存修改操作 如config.php檔案的讀取修改等操作的文章就介紹到這了,更多相關php配置檔案內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望http://www.cppcns.com