简体   繁体   中英

OpenCart require once file pathing error

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"?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM