views:

26

answers:

1

Hi,

I have the following directory tree structure:

/index.php
/code/inc/variables.php
/code/inc/config.php

index.php is the file that is called.

On our development system in: /code/inc/variables.php, when I have the line:

require_once("./code/inc/config.php");

it doesnt work and when I have:

include_once('config.php');

it does work.

The puzzle is that the first works on our development system and the second works on our production system. And there is no difference in the tree structure on either of the two systems (both run linux, different versions perhaps).

+1  A: 

If you call require_once in file DOCUMENT_ROOT/public_html/x.php:

require_once("./code/inc/config.php");

that's meen what it will be searched for file

DOCUMENT_ROOT/public_html/code/inc/config.php

if you call same require_once DOCUMENT_ROOT/public_html/code/inc/variables.php:

it will be searching for file:

DOCUMENT_ROOT/public_html/code/inc/code/inc/config.php

and of course it fails.

You can use request like this:

require_once($_SERVER['DOCUMENT_ROOT'] . "/code/inc/config.php");

and it will work in all your files correctly.

Vaidas Zilionis