You are here: Re: relative vs. absolute links in php driven pages? « PHP Programming Language « IT news, forums, messages
Re: relative vs. absolute links in php driven pages?

Posted by Erwin Moller on 03/30/06 12:26

Stephen Kay wrote:

> If you are dynamically loading pages, through php, from inside a folder
> that have relative links to images inside the same folder, into another
> document (a template) in a different folder level, the links will be
> broken.
>
> Is there some magic trick to dealing with this, or is it just better to
> never use relative links in a site that will be dynamically driven with
> php?
>

Hi,

Well, several opinions on this subject.
my 2 cents:

Your problem manifests in many forms, also with includes.
I made it a habbit to make a config-file for each PHP-project, and make a
simple function (or constant) in there that points to eg:
- absolute path (URI) to imagedirectory
something like:
function getRootDirImages(){
return "http://www.blabla.com/images/";
}

You can do the same for includes, but it is easier to overwrite a php.ini
setting for each script named include_path.
use ini_set() for that.

If you include both above every script, you have easy acces to all your
paths.

More solutions exists, but I like this one because it is easy and clean.

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация