You are here: Re: The principle of include files in PHP, not as in C++ « PHP Programming Language « IT news, forums, messages
Re: The principle of include files in PHP, not as in C++

Posted by duzhidian@gmail.com on 10/15/07 21:16

If I move the programs to other places, using absolute paths will
suffer, need to change every file.



On Oct 15, 4:56 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> duzhid...@gmail.com wrote:
> > failed to open stream: No such file or directory
>
> > I have the programs like this structure:
>
> > a.php is locate at .
> > b.php is located at ./lib
> > c.php is located at ./lib/sublib
>
> > a.php uses a function at b.php while b.php using a function at c.php
>
> > In a.php, it says: include_once(./lib/b.php) as it uses one function
> > in b.php
> > a.php is not supposed to know that b.php is using c.php, so it should
> > not include c.php.
>
> > In b.php, it says: include_once(./sublib/c.php) since it uses a
> > function in c.php.
> > b.php is not supposed to know that a.php uses itself, so it should not
> > include lib as include_once(../lib/sublib/c.php), but it does not
> > work.
>
> > The problem is: "... failed to open stream: No such file or directory
> > of c.php. .."
>
> > If using include_once(../lib/sublib/c.php) in b.php, the compiler is
> > happy. But it violates the general principle of who include files
> > only considering itself at it own position, not considering others who
> > use it (also, it is not supposed to know it) as in C++.
>
> > Any hints how to obey the above principle?
>
> > Thanks.
>
> > D.
>
> Don't use relative paths. Use absolute paths. If you're running this
> under a webserver, you can get to the web server's root with
> $_SERVER['DOCUMENT_ROOT'] and go from there.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

 

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

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