dongmei9961 2011-08-16 10:57
浏览 69

在PHP中包含不在一个目录中工作的路径

Can anybody help with the last detail of my new system. I have hit a brick wall with some php code file references trying to include files and classes. I have a script that uses Pear Mail to send SMTP e-mails and it has been working fine for years in my public_html directory at my server service on a UNIX server. I have a copy of this script in a further directory, instructorapps, in my public_HTML directory and moving it up one level has broken it. From the errors it is obviously file references in the include path which is handled by the php code:

$path = "/home/thebrigh/php";
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once ('../php/Mail.php');

This is the code that works in the public_html directory and I have tried many combinations of things to get it to work one level up. get_include_path() returns .:/usr/lib/php:/home/thebrigh/php in the working file and .:/usr/lib/php:/usr/local/lib/php:/home/thebrigh/php in the non working one. It's the middle bit /usr/local/lib/php: that I guess is causing problems but I can't seem to get rid of it.

Many Thanks Colin

  • 写回答

2条回答 默认 最新

  • dpqaaczn141761 2011-08-16 11:10
    关注

    Perhaps try require_once ('../../php/Mail.php');

    评论

报告相同问题?

悬赏问题

  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单