Reputation: 2553
I've no any problem while I use require_once() or include_once() in the same directory. But if I use like below:
I have a php class page name email.class.php where I have included the below code.
<?php
require_once('../../configuration.php'); //The file is outside of directory. (root/system/class/) where the configuration.php file is not in the class directory but in root directory
?>
now I have a subscription form where the email.class.php is included like below.
<?php
require_once('../class/email.class.php'); // Directory structure is like: (root/system/package/) // the formprocess.php is in the package folder.
?>
It seems everything correct. but when I try to process a form, a Fatal Error: require_once fail to open required ../../configuration.php file something shows. Then i tried to use URL instead of '../..configuration.php'. But my host not allows me to open URL. where is the problem ? please help me anyone. I'm just a learner.
Upvotes: 0
Views: 767
Reputation: 883
possible reasons:
check the help for more infos.. http://php.net/manual/en/function.require-once.php
Upvotes: 0
Reputation: 160973
Always use full path like require_once(dirname(__FILE__) . '/../../configuration.php');
Or require_once(__DIR__ . '/../../configuration.php')
if you php version >= 5.3
Upvotes: 1