dongsuoying9059 2011-04-20 21:16
浏览 90
已采纳

PHP配置文件读写[重复]

Possible Duplicate:
Reading and Writing Configuration Files

Okay, I have a config file, which contains some information that I would like the user to be able to change. I've already thought about holding the information in a MySQL table but this isn't a good idea as I've got my Database class included AFTER my configuration variables and this would mess up my code structure.
Any idea how to read/write variables/specific lines of a file? Here's my global config file.>

error_reporting(E_ALL);

/*
    The parameters used site-wide
    First set are Datbase parameters
    And second set are the salts used to generate strings
*/
$params['db']['host'] = 'localhost';
$params['db']['username'] = 'root';
$params['db']['password'] = 'waffliner';
$params['db']['db_name'] = 'habcms';

$params ['core']['salt1'] = "184962574320355793361124913390";
$params['core']['salt2'] = "13952134426315134482857516025";

$params['core']['timeout'] = "60 minutes";


try {
    include_once("core.inc.php");
    include_once("db.inc.php");
    include_once("user.inc.php");       
} catch(exception $e) {
    echo $e->getMessage();
}

?>

  • 写回答

2条回答 默认 最新

  • douzi8548 2011-04-20 21:27
    关注

    If you want to do so, you need to store you configuration in a non-PHP file.

    You can, for example, store your config in an .ini file and read it with parse_ini_file().

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化