Reputation: 4137
Is there any way to use a php file in the parent folder. I have a tree like this
\
- index.php
- requirements.php
\Learning Center
- index.php
When in the root folder, I can call ./requirements.php
, but i cannot do this from inside the Learning Center folder.
In an attempt to fix this, I used the full url path to the file, but now I get this error:
Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration
I cannot change the server configuration, is there any way for me to refer to the requirements.php file from inside the Learning Center folder? I do not want to resort to putting a copy of all the resources I need into each folder.
Note: Sorry if this sounds like a stupid question, but I have only been programming in php for 2 days.
Upvotes: 1
Views: 557
Reputation: 116
You can call ../requirements.php
instead. ../ is the next directory up from the current directory.
Upvotes: 1
Reputation: 272457
You can use `$_SERVER['DOCUMENT_ROOT'] to obtain the root directory.
Upvotes: 0
Reputation: 2469
Use the absolute path not the url
Eg: require '/var/www/html/learning/xyz.php' ;
not require 'www.example.com/learning/xyz.php' ;
Upvotes: 0