NYCPHP Meetup

NYPHP.org

[nycphp-talk] Closing Tags or Not Closing Tags, that is my question...

Gary Mort bz-gmort at beezifies.com
Tue Dec 18 05:45:36 EST 2007


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.





More information about the talk mailing list