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,

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.