different require_once.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

different require_once.

Post by jmut »

What is the difference if any between these two require statements.

Code: Select all

require_once(dirname(__FILE__) . '/errors.php');
require_once('./errors.php');
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: different require_once.

Post by Weirdan »

jmut wrote:What is the difference if any between these two require statements.

Code: Select all

require_once(dirname(__FILE__) . '/errors.php');
require_once('./errors.php');
First form is guaranteed to ignore include_path and the path specified is always relative to the path of the current file (while the second form may produce some unexpected results when you have a chain of included files and files have the same name on different levels of directory tree, see this comment)
Post Reply