2009-09-09 83 views
0

通过某人的建议我已经将所有PHP文件放在与htdocs相同的单独文件夹(inc)中。只有index.php留在htdocs中。因此,它是这样的:PHP无法找到我的PHP文件,如果不是在htdocs文件夹下

C:\ MyProject的\ htdocs中
- 的index.php

C:\ MyProject的\ INC
- login.php中
- util.php
- register.php
...

现在,当我在我的浏览器中的本地主机index.php处理并正确显示。但是找不到其他php文件的链接。我尝试在“inc”前加上链接,但仍未找到。我该怎么办?

我的php.ini文件中有这条线(这是在Windows上):
的include_path =;:

回答

0

我相信你需要躲避反斜杠在php.ini - “C:\ MyProject的\ INC。” - 所以它应该是C:\\myproject\\inc。但正如其他人指出的那样,您将无法使用浏览器访问包含目录中的PHP文件,因为Web服务器将不允许访问htdocs树外部的目录。

+0

我更喜欢使用斜线,但双反斜杠应该也可以(在Windows环境) – w35l3y 2009-09-09 04:15:41

1

你不能把htdocs文件夹以外的Web访问的文件,你应该使用“INC”文件夹中的文件像'database_functions.inc'不应该直接打开你的浏览器:

http://localhost/index.php // directly accessible - goes in htdocs 
http://localhost/login.php // directly accessible - goes in htdocs 
http://localhost/register.php // directly accessible - goes in htdocs 

http://localhost/util.php // you don't want people loading this file directly - put in 'inc' 
http://localhost/database_functions.php // you don't want people loading this file directly - put in 'inc' 
相关问题