xiao Posted April 19, 2008 Share Posted April 19, 2008 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... Link to comment https://forums.phpfreaks.com/topic/101922-solved-how-to-properly-use-a-configphp-file/ Share on other sites More sharing options...
xiao Posted April 19, 2008 Author Share Posted April 19, 2008 Fixed it. I was trying to use those variables inside functions ' Is there maybe a better way besides using 'global $...' everytime I need sth in a function? I don't really want to use session variables either since I already use like 30 of those. Link to comment https://forums.phpfreaks.com/topic/101922-solved-how-to-properly-use-a-configphp-file/#findComment-521611 Share on other sites More sharing options...
ToonMariner Posted April 19, 2008 Share Posted April 19, 2008 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. Link to comment https://forums.phpfreaks.com/topic/101922-solved-how-to-properly-use-a-configphp-file/#findComment-521621 Share on other sites More sharing options...
xiao Posted April 20, 2008 Author Share Posted April 20, 2008 and how do you use constants? :$ Link to comment https://forums.phpfreaks.com/topic/101922-solved-how-to-properly-use-a-configphp-file/#findComment-522001 Share on other sites More sharing options...
tippy_102 Posted April 20, 2008 Share Posted April 20, 2008 and how do you use constants? :$ Here is the information on using constants: http://ca.php.net/constants Link to comment https://forums.phpfreaks.com/topic/101922-solved-how-to-properly-use-a-configphp-file/#findComment-522012 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.