opless / phpliteadmin

Automatically exported from code.google.com/p/phpliteadmin
0 stars 0 forks source link

Ending ?> #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Low pri suggestion:

Remove the ending ?>

It's typical practice among senior PHP developers that if you're not emitting 
HTML, as in, closing PHP with ?> and starting your HTML section, that you do 
not need the ?> and in fact it can cause odd white page errors. You'll often 
see in MVC frameworks that the ?> is omitted unless actually switching the 
context to now emit HTML.

In this case, I do realize that the ending ?> is kind of a moot point because 
you're echoing the HTML all the way to the closing HTML tag. However, since 
you're not emitting any further HTML after that, you might as well emit the 
ending ?>.

Original issue reported on code.google.com by volom...@gmail.com on 30 May 2011 at 7:05

GoogleCodeExporter commented 9 years ago
So you are saying that the very end of the program, line 3082 in v1.8.6, we 
should just not have the final ?> there? Why exactly does this cause white page 
errors sometimes?

Original comment by daneirac...@gmail.com on 31 May 2011 at 7:58

GoogleCodeExporter commented 9 years ago
The ?> is only used when you want to switch context from PHP and into HTML. 
Since you're not needing to do that, that's a CPU tick you don't need to spend. 
As well, if this project were to ever expand, the ending ?> can sometimes cause 
white page errors. I've seen it. The problem occurs often in projects where a 
developer is including several files, and switching context a lot between PHP 
and HTML, and then has one file with ?> and some spaces after it. You'll get 
very hard to track white page errors. Back in 2007 I started noticing that MVC 
frameworks don't have the ending ?> in their class files, and a senior PHP 
developer explained to me that the ?> is only necessary when switching context 
into HTML.

So, yeah, it's a minor thing, and in fact it's a moot thing because you're 
already echoing the ending "</html>" tag. However, as a matter of principle, 
it's not necessary, and therefore can be eliminated without harm.

Original comment by volom...@gmail.com on 31 May 2011 at 8:04

GoogleCodeExporter commented 9 years ago
I disagree. Putting PHP code inside <? and ?> tags is a good practice, no 
matter whether this code is inside HTML or it is just pure PHP script.

Original comment by owl.brai...@gmail.com on 1 Jun 2011 at 2:40

GoogleCodeExporter commented 9 years ago
I think it's fine to have the ending tag. I did some research, and it only 
really matters when the page is used to deliver sensitive binary or xml content 
that can't have trailing whitespace. In our case of it being outputted HTML, 
trailing whitespace doesn't matter, and we can just leave the ending tag.

Original comment by daneirac...@gmail.com on 8 Jun 2011 at 3:15