Reply to Re: include problem

Your name:

Reply:


Posted by J.O. Aho on 10/11/38 11:52

Sukalyan wrote:
> Hi!
> I have a problem when i go for include any page.
> I am trying to explane that
>
> 1. let, I am working under a folder 'www'
>
> 2. under that 2 folder and 1 file.
> folder's are say 'abc', 'include'
> file is 'index.php'
>
> 3. under 'abc' has one file say 'index.php'
>
> 4. under 'include' has 4 file whose are included correctly with
> 'index.php' under 'www'
> 5. when I try to include that with 'index.php' under 'abc' I need to
> change every link within 'include' header file or rewrite a new header
> file for 'abc' folder
>
> is it possible that just changing index file of 'abc' include location
> work correctly.

When you include something without the full path in PHP, it's always the main
page relation to other files that you have to think of.

If file include/1.php includes file include/2.php, you have to use the full
path: include('/var/www/html/main/include/2.php');

Better can be to let the index files to include things, so for index.php it
would be:
include('include/1.php');
include('include/2.php');
include('include/3.php');
include('include/4.php');

in abc/index.php it would be:
include('../include/1.php');
include('../include/2.php');
include('../include/3.php');
include('../include/4.php');

another easy way to fix the paths is to use symlinks (some quite bad operating
systems don't have filesystems that supports symlinks).

cd abc
ln -s ../include

then you would have in abc:
file: index.php
symlink: include

and now you could have the same relative paths in both index.php.


//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

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