Linux/php需要父目录 [英] Linux/php require parent directory

查看:64
本文介绍了Linux/php需要父目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu 11.10上安装了apache服务器来托管我的本地网站,然后再从公司托管它.

I am on Ubuntu 11.10 and installed apache server to host my local website before i host it from a company.

我的网站根目录为"/home/a1a4a/www/"

My website root location is "/home/a1a4a/www/"

我在/home/a1a4a/www/account/account_info.php中有一个php文件"

I have a php file in /home/a1a4a/www/account/account_info.php"

我希望他在"/home/a1a4a/www/include/fg_membersite.php"中包含一个文件

That i want him to include a file in "/home/a1a4a/www/include/fg_membersite.php"

这是我在account_info.php中所做的

It's what i did from account_info.php

require_once('./include/fg_membersite.php');

我得到了这个错误

Warning: require_once(./include/fg_membersite.php): failed to open stream: No such file or directory in /home/a1a4a/www/account/account_info.php on line 10 Fatal error: require_once(): Failed opening required './include/fg_membersite.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/a1a4a/www/account/account_info.php on line 10 

那我做错了什么?怎么修 . 我具有完全权限(sudo chown -R www-data).

So what have i done wrong ? How to fix . I have full permissions ( sudo chown -R www-data ).

感恩节快乐:)

推荐答案

始终使用绝对路径,否则根据调用脚本,您将遇到错误.

Always use the absolute path or you will face errors depending on the calling script.

require_once('./include/fg_membersite.php');

实际上应该是

require_once(dirname(dirname(__FILE__)).'/include/fg_membersite.php');

这篇关于Linux/php需要父目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆