Re: Comment modes behavior in HTML and PHP

From: Date: Sat, 28 Jul 2007 17:51:33 +0000
Subject: Re: Comment modes behavior in HTML and PHP
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-259744@lists.php.net to get a copy of this message
Hi Daniel, Paul, Robert, Rick, Thanks for making it clear. Have a nice weekend. Cor ----- Original Message ----- From: "Daniel Brown" <parasane@gmail.com> To: "Paul Novitski" <paul@juniperwebcraft.com> Cc: <php-general@lists.php.net> Sent: Saturday, July 28, 2007 4:29 PM Subject: Re: [PHP] Comment modes behavior in HTML and PHP
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#259744) next »