Relative paths

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
inka
Forum Newbie
Posts: 2
Joined: Tue Jul 27, 2010 11:49 am

Relative paths

Post by inka »

Greetings!

I`m currently trying to make a webpage that is kinda based on a template, but I found a very big problem.
The pages include the header and the footer files.

The problem is when I try to create a folder and a page in it. I can change the include links for these pages but the header and footer files use realtive urls and in this subfolders none of those links or pictures work... :?

I quite new the programing and Php and I would be very grateful for a solution!
Thank you for your time and patience!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Relative paths

Post by Benjamin »

Use a base url or absolute path.
inka
Forum Newbie
Posts: 2
Joined: Tue Jul 27, 2010 11:49 am

Re: Relative paths

Post by inka »

Benjamin wrote:Use a base url or absolute path.
Thank you about the tipp.

If I use a base url for the included files, which are mostly HTML, is there a way not to exit every time from html to php if I have a link?

Better way than this:

Code: Select all

<script type="text/javascript" src="<?php echo BASE_URL; ?> includes/dom-build.js"></script>
Thank you again!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Relative paths

Post by Benjamin »

Yes, you set the base url once, in the header.
Post Reply