doupao6698 2016-10-20 00:35
浏览 198

set_include_path设置路径但路径不起作用

I've read nearly all of the posts about set_include_path but I haven't found a post that I really understand yet.

I'm trying to use UserSpice for my logins on a new site. I already have a file structure for the site of course, and I thought I would be able to simply add the UserSpice folder to that structure and then use set_include_path to access all of the files within UserSpice. But I guess I just don't understand the function or paths in general.

This is my code: set_include_path(get_include_path() . PATH_SEPARATOR . 'C:\xampp\htdocs\mynewsite\userSpice');

This is the result: Fatal error: require_once(): Failed opening required 'users/init.php' (include_path='.;C:\xampp\php\PEAR;C:\xampp\htdocs\mynewsite\userSpice') in E:\xampp\htdocs\mynewsite\index.php on line 10

The 'users' folder is a subfolder of 'mynewsite/userSpice' so I thought that the path would allow access to that folder.

Can anyone help?

  • 写回答

1条回答 默认 最新

  • dongxie1907 2018-04-08 21:42
    关注

    You have to use $_SERVER['DOCUMENT_ROOT'] to access to the required path:

    require_once $_SERVER['DOCUMENT_ROOT'] .'/mynewsite/userSpice/users/init.php';
    
    require_once $_SERVER['DOCUMENT_ROOT'] .'/mynewsite/userSpice/users/includes/header.php';
    
    require_once $_SERVER['DOCUMENT_ROOT'] .'/mynewsite/userSpice/users/includes/navigation.php';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数