你们应当知道,你通过<代码>include_once的道路在服务器上解决,而 Java脚路由浏览器解决。 两者基本遵循相同的规则:
- paths starting with
/
are resolved absolutely. On the server, this is the root directory (i.e. the topmost directory). In the browser, this is basically concatenating the host and the path that you are specifying.
- paths not starting with a
/
are relatively resolved, i.e. against the current directory on the server and against the path in your browser.
Realize that getcwd()
returns a directory like /var/www
. If you then just concanate host/source/class.ControlEntry.php
to it, it will yield /var/wwwhost/source/class.ControlEntry.php
. On most (if not, all) PHP SAPI s, you can leave out the getcwd()
thing when including a file as the current directory is already being searched when including files. In this case, you do not need the /
either.
最后,服务器文档途径不必与URLs相匹配! http://example.com/script.php 可查阅/var/www/script.js
。 如果你在超文本档案中提及/script.php
,将予以正确解决。 另一方面,你不应尝试<代码>include "/script.php>,在你档案系统根基中搜索一个文件script.php
,而这个系统往往不是你所期望的。