问个问题,各位大侠
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\*\*
路径是对的,但还是有错误,能不能打这个 \ 反过来,变成 /
