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

  • Home
  • SEARCH
  • 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 5982937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:09:32+00:00 2026-05-22T22:09:32+00:00

I am creating quite a complex web application. I like to use php to

  • 0

I am creating quite a complex web application. I like to use php to help reduce the amount of repetitive code that I end up using, creating page plugins if you like.

an example of of a section of code looks like this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>        
        <?php require_once("root/html_classes/head_links.html"); ?>
        <link href="home/css/home.css" rel="stylesheet" type="text/css" />
        <title>Texation</title>
    </head>

as you can see there is a <?php ?> reference in the above section. As this project is going to be so large I have decided to have an ultra organised file structure for all the pages, scripts, javascript, css ect elements. But it causes me 1 tiny issue.

when I create the modules linked above they themselves have references to images or other scripts and css docs that they use, but this form of inserting html means that all the directory paths need to change for every page they are inserted into, for instance,

when I use them on the index.php page the path to an image in the menu.html would be “root/images/someimage.jpg” but if I use it on the login script the path to the same image would need to be “../images/someimage.jpg”

could anyone suggest a way of making these paths dynamic taking into account the currant position within the directory structure the page they are “inserted” into is ?

I though about using php to build them something like

'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/root/images/someimage.jpg'

but cannot quite get that to work either…

Thank you for your time, any suggestions are very welcome and appreciated.

  • 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-05-22T22:09:32+00:00Added an answer on May 22, 2026 at 10:09 pm

    If you’re talking about the paths to resources, why not just use absolute paths?

    example:

     /root/images/ = http://domain.com/root/images
     root/images = [Current directory]/root/images
    

    the second one needs you to manage updating paths for every file in your site
    the first one is absolute and works every time.

    If you are having the same problem with your PHP require all you need to use is $_SERVER[‘DOCUMENT_ROOT’] . ‘/rest/of/path/from/absolute’

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

Sidebar

Related Questions

I have been creating a php application that makes quite a few queries to
For the first time I'm creating a quite complex Rails app. I'd like to
When creating a web application, and lets say you have a User object denoting
I'm creating a settings form that is quite similar to the Visual Studio 2008
When creating a new Rails application, it is automatically supplied with several quite large
Quite simply I want to be able to test that a Asp.Net web forms
I am quite new to ASP.NET. When creating new pages that already contain ASP.NET
I'm creating a touchscreen-optimized application. There are quite large buttons with labels inside of
I have successfully set up a quick test of creating a REST-like service that
Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?

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.