David Krings wrote:

So how does the parser know where PHP ends and HTML starts?

Simple, PHP starts where you have <?php (or an alternative that has been configured) and PHP ends where there is a ?> and HTML starts.

IE
<?php
// this is PHP code
?>
This is html
<?php
// this is some more PHP
?>
This is more html
<?php
//this is more PHP

// This is the end of the file


You don't need a closing tag at the end of the file if you don't place any HTML code at the end.

And since there are some operating systems where some editors will stick a blank space at the end of a file accidentally, not placing the closing ?> on the file means if some extra spaces/lines get added to the end of the file, they are not treated as HTML.


_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to