0

i write a program to Put some stuff in an database. For better organisation i want to use a config file.

In this file i want to set some variables which I want to use all over the other PHP files. For example the absolute folder wich contain all pictures

I solve this with a $GLOBALS[] Variable

For example i put in my config.php

$GLOBALS['Bildverzeichnis'] = 'www/images/';

so I can uses this in all my funtions. My question:

Is this the way to use configuration stuff?

User__42
  • 130
  • 2
  • 12
  • try to use Session ... – RïshïKêsh Kümar May 27 '17 at 15:13
  • 3
    Why would you use a session to store global config for an application? That doesn't make sense to me – Patrick Hund May 27 '17 at 15:15
  • 1
    A session should not store global configuration parameters that apply to all users. It should only store information specific to users. – kojow7 May 27 '17 at 15:17
  • There's different strategies, for instance Symfony has the [`Config` component](http://symfony.com/doc/current/components/config.html) that allows you to source it from an XML, YAML or PHP configuration source. The idea behind that is that it's cached and you could set it with overrides for development, etc. Just remember using globals means it can be overwritten, so it can bite you back. – Jared Farrish May 27 '17 at 15:17

0 Answers0