PHP 不在根目录的页面文件 include 其他不在根目录文件

基本是这个错误

我的根目录文件结构

  ..

  /conn/conn.php

  /test.test.php

test.php有

include("/conn/conn.php") 这句话

Warning: include(./conn/conn.php) [function.include]: failed to open stream: No such file or directory in D:\Program Files (x86)\AppServ\www\html4\mobile\setting_skins_mobile.php on line 1


Warning: include() [function.include]: Failed opening './conn/conn.php' for inclusion (include_path='.;C:\php5\pear') in D:\Program Files (x86)\AppServ\www\html4\mobile\setting_skins_mobile.php on line 1

无记录!


解决方法

include("../conn/conn.php") 但是不能使用你的工程的文件夹名字代替".."

参考 http://www.codingforums.com/showthread.php?t=170962

If you have gone up a level and are referencing items down a level in the directory structure you will need to let PHP know this, by preceeding your file paths with "../" Here is an example:

Assume you have the following files:

afile.php
and
directory/myfile.php

if you want directory/myfile.php to include afile.php you will need to do the following:

PHP Code:
include('../afile.php');  
or this (only if its in the sites base directory):

PHP Code:
include('./afile.php');  


posted @ 2012-07-08 11:26  sfshine  阅读(622)  评论(0编辑  收藏  举报