Re: absolute vs relative path?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/25/06, William Stokes <kalles@xxxxxxxxxxxxx> wrote:
>
>
> I Have a web site on one server and a test site on another. How can I
> build
> the hyperlinks so that they work on both servers without modification.
>

The cleanest solution is to use relative paths so that your site will work
regardless of where it's placed on the web server.  Sometimes it can be
tricky to determine what the relative path should be, but PHP can help solve
that.  Simply write a function or method to calculate the path to the base
directory of the site.  Make this a global variable and echo it before any
path to a resource on the site.

global $PATH;

echo "<a href=\"{$PATH}images/blah.gif\" />\n";

Jason

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux