在很多我的项目中,配置文件是不可短少的,个别配置文件会用变量或者数组进行设置,例如数据库、或者一些公共参数。
创立
<?php// 配置文件数组$config = array( 'DB_URL' => 'localhost', 'DB_USER' => 'root', 'DB_PWD' => 'root', 'DB_NAME' => 'test_db');// 代码格局$str = '<?php'.PHP_EOL.'/**'.PHP_EOL.'* 配置文件'.PHP_EOL.'* TANKING'.PHP_EOL.'* '.date('Y-m-d').''.PHP_EOL.'*/'.PHP_EOL.'$db_config = '.var_export($config,true) .PHP_EOL.'?>';// 创立文件$file = fopen("array.php","w");echo fwrite($file,$str);fclose($file);?>
配置文件
<?php/*** 配置文件* TANKING* 2021-04-25*/$db_config = array ( 'DB_URL' => 'localhost', 'DB_USER' => 'root', 'DB_PWD' => 'root', 'DB_NAME' => 'test_db',)?>
作者
Author:TANKING
DateL2021-04-25
WeChat:sansure2016
Web:http://www.likeyun.cn