IIS+PHP网站根目录的路径有关问题

WBOY
Release: 2016-06-13 10:18:02
Original
1155 people have browsed it

IIS+PHP网站根目录的路径问题
问个问题,各位大侠
index.php 在网站根目录,是IIS+PHP服务器

源码如下:

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';


取得错误的路径:require_once(D:\website\zufu.com.cn\uchome/includes/bootstrap.inc)

如果源码这样:

//define('DRUPAL_ROOT', getcwd());
require_once 'includes/bootstrap.inc'; //写死取得正确路径

但现在想不动源码,怎么解决这个路径的问题啊,跪求php高手指点

------解决方案--------------------
getcwd() 取得的是当前主文件所在的目录

/include.php (include include/file.php)
/include/file,php ( getpwd())
此时 getpwd 返回的是 /



------解决方案--------------------
define('DRUPAL_ROOT', dirname(__FILE__));
------解决方案--------------------
你用str_replace();替换之不就行了。
------解决方案--------------------

探讨

#5楼

这样出来的是: D\*\*

路径是对的,但还是有错误,能不能打这个 "\" 反过来,变成 "/"
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template