Jump to content

[SOLVED] how to properly use a config.php file?


xiao

Recommended Posts

I currently use something like this:

 

config.php

<?php

/**
* @author Sander Quirynen
* @copyright IPCS.be
*/

# Language

//ID of...
$instT = "1";

 

index.php

...
require ("config.php");
...

 

But I get an error on my index.php saying

Notice: Undefined variable: instT in C:\xampp\htdocs\pcconfig\index.php on line 128

I include the file on line 8...

 

IMO you should NOT use variables as configuration settings - instead use constants; after all configuration settings are constants...

 

My config files take the guise of...

 

<?php

define ( 'SETTING1' , 'setting1value'); // comment on constants meaning
?>

 

the beauty of using constants over variables lies in the memory use involved - constants are more efficient.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.