Reply to Re: Using Relative Paths With include()

Your name:

Reply:


Posted by J.O. Aho on 11/16/05 14:21

MBS wrote:
> I am playing around with some PHP code. I want to put in an include()
> function so I can include existing HTML code and output it to the browser.
>
> Lo and behold PHP does not support relative paths with the include()
> function! (How shortsighted can you get?) Is there any way at all to use
> relative paths with include()? Any hacks? If I use an absolute filepath,
> everything is fine. But I don't want to do that--I can't do that. I want
> to use the filepath relative to the currently executing PHP file.

include("../some/other/directory/the.www.html");

This works as long as as you don't make an include from an included file, as
the path is always counted from the first page.

if you have the file index.php that includes the page includes/another.php,
which in it's turn want to include yetanother.html, you still have to include
it as if you did the include from index.php

include in index.php:
include('includes/another.php');

include in another.php:
include('includes/yetanother.html');


//Aho

[Back to original 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

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