kmaid Posted September 21, 2007 Share Posted September 21, 2007 Hi i am quite new to PHP. I have lots of experience in C++ Delphi and a few other languages however working out what the path to a file is from various scripts is constantly confusing me especially when i am referring to files in a php file i have included in another PHP file. How do you all deal with this? I don’t want to give the full file path each time as these php files will be on 3-4 servers possibly more so i don’t want to have to have everything in a certain place. I was thinking about defining a constant of the base directory for everything but it seems a little extreme for something that should be quite simple. Thanks Kmaid Quote Link to comment https://forums.phpfreaks.com/topic/70199-how-do-you-deal-with-file-paths-in-php/ Share on other sites More sharing options...
rlindauer Posted September 21, 2007 Share Posted September 21, 2007 I define my system root as a property in my config object. Then I just add it ass a prefix to anything that requires a path with something like this: <?php $file = $Config->item('system_root') . 'path/to/file.php'; ?> You could also just use a global variable or something. Quote Link to comment https://forums.phpfreaks.com/topic/70199-how-do-you-deal-with-file-paths-in-php/#findComment-352600 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.