Jump to content

How to reference to a file in different location


htetnaing

Recommended Posts

Hi everyone,

 

This is driving me crazy. I need to reference different files located in different folder structure. For example, I have the following file structure.

 

/my_project/

/my_project/database/database_script.php

/my_project/index.php

 

1. If I want to reference /my_project/index.php from /my_project/database/database_script.php, how can I reference it ?

2. From /my_project/index.php to /my_project/database/database_script.php , it's obvious all I gotta do it include("/database/database_script.php").

 

I use $_SERVER('DOCUMENT_ROOT"), to solve the 1. problem. It works on my XAMPP local machine but when I uplode it onto the server, there's a problem.  The path becomes '/my_project/my_project/database/database_script.php". Is there a universal way (more like a standard way) to reference files in php so that I won't need to change every file path once I upload those onto the server ?

 

Regards,

Link to comment
Share on other sites

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.