tags:

views:

121

answers:

2

does following this work on linux server?

<? require 'foldername/header.php' ?>

the above code is present in home.php. home.php is in folder foldername.

+2  A: 

No. You want:

require 'header.php';

because you're already in foldername.

It depends on how your php.ini is set up but the default behaviour is to look in the current directory and the include directory or directories (if any) so "foldername/header.php" is relative to the path of the home.php script.

cletus
It is relative to the path of the invoked script. (e.g: index.php)
erenon
A: 
echo get_include_path() . ';' . $_SERVER['DOCUMENT_ROOT'];

This will show you the directories that require() will be relative to.

It will probably start with ".;" with the DOCUMENT_ROOT will describe literally.

simplemotives