Re: Comment modes behavior in HTML and PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/28/07, Paul Novitski <paul@xxxxxxxxxxxxxxxxxxx> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux