Re: Full versus relative URLs

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

 



2009/2/17 PJ <af.gourmet@xxxxxxxxxxxx>:
> Stuart wrote:
>> 2009/2/17 PJ <af.gourmet@xxxxxxxxxxxx>:
>>
>>> Dotan Cohen wrote:
>>>
>>>>>> So put it all in one place:
>>>>>>
>>>>>> <?php
>>>>>> include "path.inc";
>>>>>> print"<a href=\"$path/dir/file.php\">";
>>>>>> ?>
>>>>>>
>>>>>> Full URLs don't break when users save the pages to disk.
>>>>>>
>>>>> That would be fine if the pages weren't being crafted in Dreamweaver,
>>>>> where inserting links like that is a pain.
>>>>>
>>>>>
>>>> For that you'd have to ask on the Dreamweaver list. I don't really
>>>> like those tools.
>>>>
>>>>
>>> I hope I'm not out of place here, but I have a problem that seems to be
>>> related.
>>> I am using some include statements for page headers with the pages in
>>> various directories on the site. The problem is this... if I put
>>> relative statements in the page (header.php) like ../images/file.jpg and
>>> ../file.php etc, if the page into which I include header.php is not in
>>> the top level directory, the links do not work and I have to copy
>>> header.php to header1.php and change the references to /images otherwise
>>> images are not displayed and links to not work in href.
>>>
>>> e.g.:
>>> 1.  top level file books.php
>>> include ("lib/db1.php");    // Connect to database
>>> include ("header1.php");
>>>
>>> 2. subdirectory: /authors/a.php
>>> include "../header.php";
>>>
>>> I thought that using referencing the top level of the directory tree
>>> (../) would work form anywhere within the tree?
>>> Am I the victim of my own misconceptions here?
>>> TIA to set me straight.
>>>
>>
>> Personally I always include files relative to my current location
>> using the following...
>>
>>     include dirname(__FILE__).'/lib/db1.php';
>>
> Could you clarify, please? I don't understand. And example, perhaps?
> my entry in books.php is
> <?php include "../header.php";?>
> NOTE: Does it matter what

<?php include dirname(__FILE__)."/../header.php"; ?>

Simple as!

-Stuart

-- 
http://stut.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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