PHP include absolute path

You can’t include php files relatively to your webroot that way, cause if you use the slash as first character, the reference will go much deeper than just your document root. So, instead of using your basepath, you could do something like this : <?php $path = $_SERVER[‘DOCUMENT_ROOT’]; $path .= “/yourpath/yourfile.php”; include_once($path); ?>

How to avoid using relative path imports (/../../../redux/action/action1) in create-react-app

Create a file called .env in the project root and write there: NODE_PATH=src Then restart the development server. You should be able to import anything inside src without relative paths. Note I would not recommend calling your folder src/redux because now it is confusing whether redux import refers to your app or the library. Instead … Read more

How to get the file-path of the currently executing javascript code

Within the script: var scripts = document.getElementsByTagName(“script”), src = scripts[scripts.length-1].src; This works because the browser loads and executes scripts in order, so while your script is executing, the document it was included in is sure to have your script element as the last one on the page. This code of course must be ‘global’ to … Read more

Absolute vs. relative paths

you should use a config file that will be included in each file first line, for example your app look like this root / App / Plugins inside your root dir : app-config.php if ( !defined(‘ABSPATH’) ) define(‘ABSPATH’, dirname(__FILE__) . “https://stackoverflow.com/”); now, suppose you have to include a plugin file, so inside your Plugin dir … Read more