Is there a PHP reference manual?
I know how to include files in folders further down heirachy, but I'm having trouble finding my way back. I decided to go with the default set_include_path, everything further includes relative to level 2 paths up, but have no idea how to write it.
Is there a reference somewhere that specifies the path that links to PHP?
source to share
it might be easier to just use the absolute path to the link:
set_include_path('/path/to/files');
thus you have a guideline for your entire future. including are handled relative to the point they called, which can cause some confusion in certain scenarios.
as an example, given the folder structure ( /home/files
):
index.php
test/
test.php
test2/
test2.php
// /home/files/index.php
include('test/test.php');
// /home/files/test/test.php
include('../test2/test2.php');
if you call index.php it will try to include the following files:
/home/files/test/test.php // expected
/home/test2/test2.php // maybe not expected
which may not be what you expect. the call to test.php will call /home/files/test2/test.php
as expected.
the conclusion is that inclusions will be relative to the original calling point. to clarify, it affects set_include_path()
if it is relative. consider the following (using the same directory structure):
<?php
// location: /home/files/index.php
set_include_path('../'); // our include path is now /home/
include('files/test/test.php'); // try to include /home/files/test/test.php
include('test2/test2.php'); // try to include /home/test2/test2.php
include('../test3.php'); // try to include /test3.php
?>
source to share