Jump to content

Recommended Posts

Hi all,

 

I have been looking at some code for a chaps site (ober has too) and had a question.

 

The particular site has a config file and uses parse_ini_file to grab all the variable/value pairs then loops through and creates a constant for them all.

 

I personally have config files that are simply a set of define statements to set constants and their values.  Not with standing the fact that and extra level of processing is involved what is the benefit of the parse_ini_file and subsequent define method?

Link to comment
https://forums.phpfreaks.com/topic/56677-config-files/
Share on other sites

err if you read the last line it says

 

what is the benefit of the parse_ini_file and subsequent define method?

 

I suppose I should add

 

'over just defining constants...'

 

MY config files look liek this

<?php

define('DBHOST' , 'localhost'); // db server.

define('DBNAME' , 'xyz'); // database name.

...

define('INCLUDEDIR', '/includes/');

?>

 

the method I have seen in this other code has a config.ini file very similar to php.ini in structure

 

the code uses parse_ini_file();

 

then takes all the parameters form that and loops through each and defines a constant with the parameter name and assigins its value.

 

Just wanted to know why you would use a .ini file and then use define on all parameters when you could simply use a file full of define staements in the first place.

Link to comment
https://forums.phpfreaks.com/topic/56677-config-files/#findComment-280050
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.