Re: Comment modes behavior in HTML and PHP

From: Date: Sat, 28 Jul 2007 15:29:52 +0000
Subject: Re: Comment modes behavior in HTML and PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-259743@lists.php.net to get a copy of this message
On 7/28/07, Paul Novitski <paul@juniperwebcraft.com> wrote: > At 7/28/2007 07:40 AM, C.R.Vegelin wrote: > >I have a PHP script, as follows: > ><!-- > > <?php > > echo "should this be echoed ?"; > > ?> > >--> > > > >As expected, the browser shows nothing, > >but when I view Source in the browser, I see: > ><!-- start HTML comment > > should this be echoed ?--> > > > >Shouldn't it be just: <!-- -->, without the echo result ? > >I don't expect PHP to be active between <!-- -->. > > > <!-- ... --> is an HTML comment. > > /* ... */ and //... are PHP comments. > > The HTML comment syntax does not affect PHP, and PHP comment syntax > does not affect HTML. > > http://www.php.net/manual/en/language.basic-syntax.comments.php > > Regards, > > Paul > __________________________ > > Paul Novitski > Juniper Webcraft Ltd. > http://juniperwebcraft.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Taking a moment to explain the WHY of what's happening should help you understand it a bit more, Cor. All HTML markup - including comments - is parsed on the browser side, while PHP is done on the server side. The server doesn't parse HTML at all, and PHP doesn't have any knowledge of it's position within a script, or what else exists outside of the <? ?> tags. Thus, PHP is parsed, compiled, and executed prior to the web server serving the end-result as pure HTML, which is then parsed by the browser upon receipt. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107

« previous php.general (#259743) next »