Include files from parent or other directory
include()
and its relatives take filesystem paths, not web paths relative to the document root. To get the parent directory, use ../
include('../somefilein_parent.php');
include('../../somefile_2levels_up.php');
If you begin with a /
, an absolute system file path will be used:
// Full absolute path...
include('/home/username/sites/project/include/config.php');
Include files from parent directory
The only thing that comes to my mind right now is the current working directory.
If you don't specify an absolute path the current working directory will be chosen.
E.g.
<?php
chdir("/tmp");
include "test.php"; // will include /tmp/test.php
And
<?php
chdir("/home/marco");
include "test.php"; // will include /home/marco/test.php
Try changing your path to: __DIR__."/../vendor/autoload.php"
.
See PHP: Magic Constants for further reference.
Include file from parent folder
Check.php
<?php
include "../src/connect.php";
the two dots ..
refer to the parent directory.
php.net
include
require
Include PHP file from parent sibling folder in word press
Finally, I found the solution.
just put the dirname(__FILE__)
function before the directory that I want to include.
This function will get the directory path that files that I write this function to it.
for example, if file be at C:\xampp\htdocs\amt-master\wp-content\themes\wp-bootstrap-child
it returns this path
But as my case, I want to get the previous path to do that I should just put this function in the same function like this
include dirname(dirname(__FILE__))."/filename.php"
then it will return this path
C:\xampp\htdocs\amt-master\wp-content\themes
then you can write remaining path.
Importing modules from parent folder
It seems that the problem is not related to the module being in a parent directory or anything like that.
You need to add the directory that contains ptdraft
to PYTHONPATH
You said that import nib
worked with you, that probably means that you added ptdraft
itself (not its parent) to PYTHONPATH.
Related Topics
PHP - Get Numeric Index of Associative Array
A Better Approach Than Storing MySQL Password in Plain Text in Config File
How to Hide the Actual Download Folder Location
Process CSV into Array with Column Headings for Key
How to Enable and Use Http Put and Delete with Apache2 and PHP
How to Detect the Browser with PHP or JavaScript
Php.Exe' Is Not Recognized as an Internal or External Command, Operable Program or Batch File
PHP File Upload: Mime or Extension Based Verification
Woocommerce Change Loading Spinner Icon
Proper Url Forming with a Query String and an Anchor Hashtag
Run Cron Job on PHP Script, on Localhost in Windows
Switching Between Http and Https Pages with Secure Session-Cookie
Counting Occurrence of Specific Value in an Array with PHP
Preg Match Text in PHP Between HTML Tags
Logging in to Joomla 1.5 Using External Form (Not Within Joomla Folder, But on Same Server)
$_Files Field 'Tmp_Name' Has No Value on .Jpg File Extension