Alex Rivera | Logout

my_config.ini vs my_config.php

Asked 2009-05-05T04:31:02.610
17

At work we use a .ini file to set variables prior to calling the rest of the framework (I think it goes

function getConfigVars(){
    //read my_config.ini file
    ....
    //call framework
}

and I have always wondered if there was a benefit to doing it that way.

It seems to me that you then have to write access rules to stop people from looking at it from the web and php has to parse it and understand it.

So, why use my_config.ini rather than my_config.php? It is not like anyone should be touching it after it is set up and it seems more convenient to just call the variables and be able to have your IDE auto complete the text wherever you are using the ini variables / parse it for errors.

Edit
Report

1 Answer

1

Well it might be easier for a non programmer to modify config variables... If that's necessary at your workplace.

I've discovered careful placement of the <?php and ?> can stop it from being displayed, whilst the parse_ini_file() will still get the relevant data from the file.

Best way to secure it though, is to place it above the docroot, and deny access to *.ini in your server setup.

answered 2009-05-05T04:34:00.093

Your Answer