Creating a config file in PHP

前端 未结 10 2135
难免孤独
难免孤独 2020-11-27 10:36

I want to create a config file for my PHP project, but I\'m not sure what the best way to do this is.

I have 3 ideas so far.

1-Use Variable<

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 11:03

    One simple but elegant way is to create a config.php file (or whatever you call it) that just returns an array:

     'localhost',
        'username' => 'root',
    );
    

    And then:

    $configs = include('config.php');
    

提交回复
热议问题