dongxie548548 2015-02-19 20:05
浏览 11

OpenCart需要一次文件路径错误

So I have a require once in a newsletter.php file and I cannot get the file path to take. On a side note if I hard code the path it works but I have multiple environments on different servers so I don't want to hard code this. The current file path of my file is /var/www/cbnni-b2c-www/dev/current/catalog/controller/module/newsletter.php and the require once file path hard coded looks like this require_once '/var/www/cbnni-b2c-www/dev/current/Ctct/autoload.php' so what I am trying to do is.

require_once (__DIR__.'/../../../Ctct/autload.php')

and every different variation of this but nothing seems to work. So what I am thinking is vqmod is taking control of this newsletter.php and the file path is changing but I dont know what this file path is or how to find out what it is because when in the file I try to var dump or echo the DIR with $path = getcwd();but it gives me an error and won't run the newsletter.php file. So my question is first am I missing something and not writing the file path correct on. require_once (__DIR__.'/../../../Ctct/autload.php') second how can I find the path of the file when I cannot echo or var dump from within that file?

Is there a way to get back to the root of your project folder when you don't know where you are at in your file path. Such as go back directories and stop when you hit "/current"?

  • 写回答

1条回答 默认 最新

  • dongrang9300 2015-02-19 20:16
    关注

    Spot the difference:

    require_once '/var/www/cbnni-b2c-www/dev/current/Ctct/autoload.php'
                                                             ^----
    
    require_once (__DIR__.'/../../../Ctct/autload.php')
                                             ^---
    

    If you're doing this in a file that can't do debug echoes, then you can always use error_log(), which will write your message out to the error log file.

    评论

报告相同问题?

悬赏问题

  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错