Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:44:43+00:00 2026-06-14T04:44:43+00:00

My website contains multiple files organized in directories. More specifically, this is my structure:

  • 0

My website contains multiple files organized in directories. More specifically, this is my structure:

  • index.php
  • pages/account/viewaccount.php
  • pages/account/createaccount.php
  • pages/account/editaccount.php
  • pages/aboutus/aboutus.php
  • src/php/functions.php

If you have trouble understanding this or require more information, add a comment

Within my functions.php, I create a link to refer to my index file. Since this function is called by all my main .php files, the path to the index file varies dependent on the page calling the function.

For example, if the function is called by my index file, the path would obviously be “index.php”. However if the function is called from my viewaccount.php file, the required path would be “../../index.php”

Therefore my problem is:

How can I set a general path, which independent from which file I call my function, it will always link correctly to my index file.

Once quick fix is to put all my main php files as siblings to my index, but I want to keep all my files organised

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:44:44+00:00Added an answer on June 14, 2026 at 4:44 am

    The way most of the php frameworks work is similar to the following, zend framework works like this:

    Declare a constant APPLICATION_PATH and then make all the paths relative to this one.

    define("APPLICATION_PATH", "/var/www/mysite");
    

    And then all your requires will be relative to your APPLICATION_PATH.

    require_once APPLICATION_PATH ."/system/helpers/{$helper}.php";
    

    * With this approach you can include files from whatever script without issues. Because all the paths are going to be relative to your APPLICATION_PATH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website that contains company profiles. These profiles have many pages within
I have made a navbar at the top of my website which contains multiple
I have a website that contains many different pages of products and each page
I used php on my website so it can display multiple languages. I noticed
On my site, I have a PHP script which takes multiple source files (HTML,CSS,
Hi I am trying to create a one page website that contains multiple div's
My website contains : 1.FancyBox (for image overlay) 2.GalleryView (a slider) and both use
I have a website which contains a large (and wide) table. The table is
I got a website which contains a lot of projects with each project containing
I have a website that contains a list of articles. I want to include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.