PHP Dynamic include based on current file path
Posted
by Adrian M.
on Stack Overflow
See other posts from Stack Overflow
or by Adrian M.
Published on 2010-04-11T17:23:44Z
Indexed on
2010/04/11
17:33 UTC
Read the original article
Hit count: 283
Hello,
I want to find a method to include some files based on the current file path.. for example:
I have "website.com/templates/name1/index.php", this "index.php should be a unique file that I will use in many different directories on different depths, so I want to make the code universal so I don't need to change anything inside this file..
So if this "index.php" is located in
"website.com/templates/name1/index.php"
than it should include the file located here:
"website.com/content/templates/name1/content.php"
another example:
"website.com/templates/name2/index.php"
than it should include the file located here:
"website.com/content/templates/name2/content.php"
Also I want to overrun "*Warning: include_once() [function.include-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0*" kind of error.. because is disabled and unsafe..
Is there a way to achieve this? Thank you!
© Stack Overflow or respective owner