Ok, I am creating an admin interface for my custom blog at the url /admin.
Is it possible for me to be able to use the same includes (including autoload), as the root directory.
If possible, I would also like to be able to automatically correct the links in the navigation so that they go that index.php in / changes to ../index.php when accessed from /admin.
Thanks, Nico
You need to try the path of functions. php within the system and not its url. Do you have console access? If so just find out what directory is the file in and include it using the full path.
PHP Include Files. The include (or require ) statement takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement. Including files is very useful when you want to include the same PHP, HTML, or text on multiple pages of a website.
The best practice for this is to define a 'ABSOLUTE_PATH' constant that contains the directory that everything is located under. After that, you can simply copy and paste everything, because it is defining the 'full' path, which doesn't change from directory to directory.
Example
define("ABS_PATH", $_SERVER['DOCUMENT_ROOT']);
or
define("ABS_PATH", dirname(__FILE__));
// This defines the path as the directory the file is in.
Then at any point you can simply do this to include a file
include(ABS_PATH . "/path/to/file");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With