Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/70199-how-do-you-deal-with-file-paths-in-php/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.