|
Posted by gosha bine on 05/28/07 18:20
Michael wrote:
> Since the include function is called from within a PHP script, why
> does the included file have to identify itself as a PHP again by
> enclosing its code in <?php> ... <?>
>
> One would assume that the PHP interpreter works like any other, that
> is, it first expands all the include files, and then parses the
> resulting text. Can anyone help with an explanation?
Unlike, say, C preprocessor instructions or java's imports, php
include() is executed when your script runs, not when it compiles. When
interpreter encounters an "include", it reads the given file and
evaluates its context as php code. "include" is just a confusing name,
"included" files are actually not "embedded" in main file.
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
[Back to original message]
|