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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值