开发者

php using files in the parent folder

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.


You can call ../requirements.php instead. ../ is the next directory up from the current directory.


Use the absolute path not the url

Eg: require '/var/www/html/learning/xyz.php' ;

not require 'www.example.com/learning/xyz.php' ;


You can use `$_SERVER['DOCUMENT_ROOT'] to obtain the root directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜