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 Jerry Stuckle on 10/16/07 13:04

Tim Roberts wrote:
> Jerry Stuckle <jstucklex@attglobal.net> wrote:
>
>> duzhidian@gmail.com wrote:
>>> I can organize the codes, but it does not seems as transparent as what
>>> c/c++ does as one file at root have to consider it's grandsons'
>>> functions (location), not supposed to do that in c/c++.
>> You're still using relative paths. Anything starting with ".", ".." or
>> a path name is relative.
>>
>> Absolute paths start with / in linux/unix.
>>
>> It works exactly the same in C/C++. Relative paths there are relative
>> to the executable.
>
> You missed the point. He's talking about #include files, and he is quite
> correct. In C/C++, you never ever ever use an absolute pathname in an
> #include statement. Further, the preprocessor rule is that relative paths
> in an #include statement are relative to the directory that contains the
> file being scanned.
>
> PHP's rules are different. Not better, not worse. Just different.

No, you missed the point.

Compilation is not the same as execution. When PHP is executed, it's
include statement works just alike any file operation in C/C++ when that
program is executed.

Just because they are both "include" statements does not mean they are
the same. In PHP they are executed. In C/C++ they are handled by the
preprocessor. Completely different environment with completely
different results.

And you are incorrect. In C/C++, include files are relative to the list
of directories in the -I (INCLUDE) compiler option (which can also be
specified in some IDE's). And you can use absolute paths in #include
statements.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@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

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