What I know its a best practice to leave the closing tag in a script
with one php opening tag.Mostly this applies in a script that present a
class, I think its not correct to leave closing tags in  template kind
of script where you have several php tags.

Gr
Muhsin


On 07/24/2011 02:33 PM, Geoff Lane wrote:
> Hi All,
>
> While watching one of Jeffrey Way's CodeIgniter tutorials, I was
> gobsmacked when he noted that it was best practice not to have closing
> PHP tags as closing tags might introduce whitespace issues. So I tried
> syntax checking a few simple pages and, to my surprise, the syntax
> checkers accepted the pages even though the closing "?>" was missing.
>
> However, I suspect that there may be issues with this. For example,
> what happens if you include or require something that has no closing
> PHP tag? For example, consider two files:
>
> File: test_inner.php ----------------8<--------------------------
> <?php
>   echo "This is the inner code\n";
> ---------------------------8<------------------------------------
>
> File: test_outer.php ----------------8<--------------------------
> <html><head></head><body>
> <?php
>   include ('test_inner.php');
>   echo "This is the outer code\n";
> ?>
> </body></html>
> ---------------------------8<------------------------------------
>
> I thought that there might be an issue with the parser attemting to
> parse the closing body and html tags as PHP, so I ran a check on one
> of my development machines with the above files and there was no
> error. It seems that, on my development machine at least, a PHP code
> block can be closed either explicitly (with '?>') or implicitly by the
> EOF! However, experience has shown me that what works on one server
> might not work on all of them as there are so many configuration
> options and so many versions of PHP 'in the wild'.
>
> So, is Jeffrey correct when he says that omitting the closing PHP tag
> is best practice? Also, are there any 'gotchas' to doing this?
>
> TIA,
>


-- 
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,PHP,SQL,HTML
Typo:40WPM
url:http://www.mzalendo.net
url:http://www.zanbytes.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to