Sulman Posted February 29, 2008 Share Posted February 29, 2008 Hi all, Is there anything in PHP.ini that will allow me to dynamically alter paths? e.g.: <?php include('/usr/webdata/site/includes/inc.php') ?> php will then see that and rewrite it to 'mysite/includes/inc.php' then go off and get it. Is this possible or am I barking up a non existent tree here? Thanks Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/ Share on other sites More sharing options...
GingerRobot Posted February 29, 2008 Share Posted February 29, 2008 Yeah, it is possible. You need to modify your include path Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480016 Share on other sites More sharing options...
rhodesa Posted February 29, 2008 Share Posted February 29, 2008 Yeah, it is possible. You need to modify your include path Altering the include path won't matter if you are using absolute paths. To my knowledge there is no way to override that functionality. You could write your own function, maybe call it include2() and have that alter the path before doing the include. Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480019 Share on other sites More sharing options...
GingerRobot Posted February 29, 2008 Share Posted February 29, 2008 Yeah, sorry, i meant to point that out. I meant to say that it might be an option to use relative links instead. Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480027 Share on other sites More sharing options...
Sulman Posted February 29, 2008 Author Share Posted February 29, 2008 Hmmm thanks. But I am trying to set up a mirror dev version of the site on my local machine. So changing the files is not an option. It is going from unix to windows and there are alot of occasions where the full path on the server is used (/usr/webdata/mysite/includes/), but on my local windows machine that path will actually be 'C:\www\mysite\includes' Any ideas how I may overcome this? Thanks Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480085 Share on other sites More sharing options...
PFMaBiSmAd Posted February 29, 2008 Share Posted February 29, 2008 You should be using $_SERVER['DOCUMENT_ROOT'] to form your absolute server paths. Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480089 Share on other sites More sharing options...
Sulman Posted February 29, 2008 Author Share Posted February 29, 2008 You're right...but this is existing code from before my time...so I'm afraid I'm stuck with the hand coded path. Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480094 Share on other sites More sharing options...
rhodesa Posted February 29, 2008 Share Posted February 29, 2008 The only thing I can think of is to create the folder: C:\usr\webdata\mysite\ and put the website in there. You will have to alter your apache config to point there instead though. That should work though because PHP on windows will interpret /usr/webdata/mysite/includes/ as C:\usr\webdata\mysite\includes\ But, your best solution is to fix your product and use relative paths. I would avoid $_SERVER['DOCUMENT_ROOT'] because you could technically have your website outside of Document Root and then point Apache to it with a ScriptAlias (which I use all the time). Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480098 Share on other sites More sharing options...
Sulman Posted February 29, 2008 Author Share Posted February 29, 2008 Hmmm, Ok, thanks for your replies. Think I might have to have a rethink and sort the paths out properly. Thanks all! Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-480199 Share on other sites More sharing options...
nolochemical Posted June 24, 2008 Share Posted June 24, 2008 ??? I have a similar question, I wanted to dynamically access higher level paths.. Ex.. htdocs/mysite/myFirstScript points a links to htdocs/mysite/inc/myFunctionsScript that will need to write to myFirstScripts directory(not absolute) or a folder on the same level.. I have my script working so that it gets the target url, but having trouble with the logic.. and possibly the syntax. I'm thinking using '../' to go up one directory and find the path from there, but is there an easier way? I have been reading so many threads on the net arguing the meaning of each of following, much-less the best time to use each(on a *nix/apache host): current: /public_html/ /somepath ./somepath ../somepath I wish this was a part of - or I could find - the code/snippets. Please excuse me for piggy backing the thread, yet the problem was very similar to start a new thread. Any thoughts.. ??? humblest thanks, Nolo Link to comment https://forums.phpfreaks.com/topic/93686-dynamic-path-mapping/#findComment-573472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.