Reply to Re: Why does include file text need to be bracketed by <?php> ... <?>

Your name:

Reply:


Posted by Michael on 05/28/07 19:01

On May 28, 11:46 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Michael wrote:
> > On May 28, 10:05 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com>
> > wrote:
> >> "Michael" <MichaelDMcDonn...@yahoo.com> wrote in message
>
> >>news:1180370371.580860.72150@x35g2000prf.googlegroups.com...
>
> >>> On May 28, 9:24 am, Darko <darko.maksimo...@gmail.com> wrote:
> >>>> On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com> wrote:>
> >>>> "Michael" <MichaelDMcDonn...@yahoo.com> wrote in message
> >>>>>news:1180368213.786423.310320@z28g2000prd.googlegroups.com...
> >>>>>> 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?
> >>>> It's not supposed to be bracketed by <?php> and <?>, but by <?php
> >>>> and ?
> >>>>> . That's not necessary, though. You have to put those symbols into
> >>>> your require-d file if you want it to be understood like php code, but
> >>>> if you don't, it will be understood as raw output. Just like any other
> >>>> php file:
> >>>> <?php
> >>>> if ( $x ) {
> >>>> ?>
> >>>> some output here
> >>>> some output here
> >>>> some output here
> >>>> <?php
> >>>> } else {
> >>>> ?>
> >>>> some other output here
> >>>> some other output here
> >>>> some other output here
> >>>> <?php
> >>>> }
> >>>> ?>
> >>>> As for the require-d file, the same counts - if you didn't put <?php
> >>>> and ?> surrounding the contents of the file, they would be understood
> >>>> as ordinary output, not php code (which, of course, can be exactly
> >>>> what we wanted).
> >>>>> Because a php can contain other text such as html... the parser is only
> >>>>> signaled to work on the block that is inside a the php tag...
> >>>>> you ever wonder why <? php ?> looks like an html tag? cause it is!
> >>>> I wouldn't go that far to say <?php and ?> are html tags, although
> >>>> they do resemble them having lt and gt chars. Actually, the <? and ?>
> >>>> are part of xml processing instruction declaration syntax, so when we
> >>>> say "<?php" we say "give the following contents to php", and when we
> >>>> say "?>", we actually say "those contents end here". So, php code is
> >>>> actually organized as xml document, and html out of <?php ?>
> >>>> instructions perfectly fits in that concept, being itself a subset of
> >>>> xml, although older than xml.
> >>> =====================
> >>> I guess I'm still missing the point. Once the browser interpreter sees
> >>> the <?php, it assumes that all text to follow is php code until the
> >>> terminating token ?> is seen. Now if the include function is called
> >>> within the <?php ... ?>, the interpreter still assumes that any text
> >>> it sees is PHP. So again, I don't understand why the include text
> >>> needs to bracket its code in <?php ...?>. What am I missing here?
> >>> Thanks, MDM.
> >> Thats your problem... php has nothing to do with the browser. Its a server
> >> side scripting language and independent of the client.- Hide quoted text -
>
> >> - Show quoted text -
> > =============================
> > Yes, the text "browser interpreter" should replaced by "interpreter".
> > In any case, it would seem that the question is still valid. Any
> > comments would be appreciated.
> > MDM
>
> Michel,
>
> Because the included file may not necessarily contain PHP code. It can
> contain html, for instance, with php code intermixed - just like any php
> file. Or it may contain no php code at all.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Hide quoted text -
>
> - Show quoted text -

======================
Thank you all for your very helpful answers to my question.

[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

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