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

来源:互联网 发布:商品数据库张国良 编辑:程序博客网 时间:2024/05/21 11:03

基本是这个错误

我的根目录文件结构

  ..

  /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');  


原创粉丝点击