0

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 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

It is relative to the path of the invoked script. (e.g: index.php)
0
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.