Jump to content

Coder_Mediocre

New Members
  • Posts

    2
  • Joined

  • Last visited

Coder_Mediocre's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, I had no idea there was a WEB_ROOT that differed from DIR_ROOT. I suppose the question I'm asking is, do I include the config.php file in a class.php file and build file paths from it, or do I continue to refer to paths in a relative sense i.e. 'uploads/image1.jpg.' as the class file is already being included via the loader in the root directory files where $config['app_dir'] already exists? My application works when relative paths are used, but sends out '$config = undefined variable' when I include the config file and try and build the path using $config[app_dir']. Should I just refer to the filepath in a relative sense?
  2. Hi, I'm trying to put some some closure on my understanding of absolute file paths in php. Say I have the following folders with the following files: ROOT/ 'index.php' ROOT/ INCLUDES/ 'config.php' 'load.php' 'database.class.php' ROOT/ UPLOADS/ image1.jpg I have 'config.php' in ROOT/INCLUDES which has the absolute path to the application root directory, which I have coded as $config['app_dir'] = dirname(dirname(__FILE__)); In all my ROOT folder files, such as index.php, I have the following lines at the beginning of the file, which seems to be working: require_once dirname(__FILE__).'/includes/config.inc.php'; include_once $config['app_dir'].'/includes/load.php'; I'm having difficulty understanding how to integrate config.php as an include statement in database.class.php (there are a number of methods in the class of database.class.php called by index.php that build file paths). I've tried excluding the above two lines from the start of database.class.php and simply refer to the files in the class simply as 'uploads/'image1.jpg'. While this works, I'd like to incorporate the above lines for portabilities sake (i.e .$config['app_dir'].'/uploads/image1.jpg.) If I do, however, the browser states $config is an undefined variable. Have I misunderstood the nature of the role of $config['app_dir'] in the config.php file and in actual fact there is no need to refer to the path of image.jpg, as 'uploads/'image1.jpg' will simply do because the database.class has already been called by index.php, where the absolute file path building takes place?
×
×
  • 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.