Using two different php files with very different paths on a host machine: api.php
and api2.php
, How can one use an include statement to freely use all the code in api2.php
in api.php
. The path of the api2.php file that should be included is Desktop > PushChatServer > Api
. The path for the api.php
file is Desktop > HtDocs > Folder1
Is this how one would correctly specify an include/require path in the api.php
file to successfully use the data from api2.php
?
require_once 'Desktop/PushChatServer/api2.php';
Or would the following work though both files have different paths?
require_once 'api2.php';
Source: Files are included based on the file path given or, if none is given, the include_path specified.
http://php.net/manual/en/function.include.php
I want o make sure the script reads the right path. Is it possible to use this type of path in a require statement?
To get the exact path of the file you're using open it in Text Wrangler (free for download). Once the file is opened in text wrangler go to where it says copy path
and you can then pick a multitude of options ranging from copy the url (text wrangler will generate one for your file) or copy full path (text wrangler will generate the full path). In my case it was this
require 'file://localhost/Users/user/Desktop/PushChatServer/api/api.php';
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.