[wp-hackers] Discussion about Optional Closing PHP tags in the WordPress Library

Jacob Santos wordpress at santosj.name
Thu Jun 19 00:34:16 GMT 2008


I should probably correct you in saying that I already know that the 
closing PHP tag is optional and have known about it for about a year or 
two now. You may notice the title and the various references in my 
original post pointing that out. I don't need people "correcting" me on 
something I'm already well aware of.

If you read the sentence again, you might notice I was speaking in the 
voice of /other people/ and not of myself. You are the second person to 
take out the context the sentence and twist it into something it is not. 
If I didn't write clearly enough, then I'm sorry I didn't explain it 
better for those who like flame-baiting, same goes for the other guy. It 
is obvious that both the subject line and the various hints that I know 
what I'm talking about didn't quite get through to the both of you.

I would write next time, "I know what I'm talking about!" However the 
previous attempts with that disclaimer have backfired quite badly, so 
I'm not going to start doing that again.

On the subject of Coding Standards, there are advantages and 
disadvantages, so much so that you are pissing in the wind trying to 
debate the subject. Which is why I stopped after the first attempt to 
get the closing PHP tag removed. You should be wise to do the same, 
because it isn't going to happen. Something that is a matter of 
preference is very difficult to debate, because there are hardly any 
"facts" that will convince someone otherwise.

This discussion is not about convincing the commit team that the closing 
PHP tag should be removed. From you reply, it appears to be a bigger 
issue than I had thought. From the codex references, it also appears 
that those on the forums aren't using Google to their advantage. I 
suggest stop answering their questions or pointing them to Google.

You know, I really wish I had saved that page, but alas I'm not going to 
spend an hour or two finding the page again. What it comes down to was 
that the senior developer of PHP was telling the novice user of PHP, 
that since the novice did not realize that it could be removed, that the 
novice should not remove it. When you get into optional parameters, the 
novice might forget that in some instances it is required and until the 
novice realizes when the closing PHP tag is required and when it is not, 
then the novice user should always have the closing PHP tag.



Otto wrote:
> This is the recommended coding standard for virtually all PHP projects
> out there, WordPress being the notable exception.
>   

This was also one my main points back when I did debate the issue. Look 
where we are now? At the same place where the closing PHP tag is still 
required in WordPress as a Coding Standard. Funny huh?

>   
>> Really, from the commonly quoted message on the subject, the conclusion
>> translates to that it is better to have the closing PHP tag, so that those
>> who don't know better don't get tripped up on the small stuff. Whether or
>> not WordPress should have the closing PHP tag is not at issue here. How is
>> this problem, when it occurs troubleshooted for users?
>>     
>
> No, actually the correct conclusion is that it is better to omit the
> closing tag in all cases where it is not needed. And, in fact, I
> recommend people remove it from wp-config on a regular basis.
>   

You should read the ticket I referenced in the original post. You will 
recognize that I also mention the same advice. If you notice the 
timestamp, then you will notice that it came before your post on this 
matter.

> This is, in fact, a huge and often repeated problem that occurs
> regularly on the support forums. So much so that we have made several
> statements in the codex about it. Search the forums for "Cannot modify
> header information - headers already sent". This is almost always
> caused by a blank line somewhere.. And 80% of the time it's in the
> wp-config.php file.
>   

Ah. So there is some firewood for switching. However, the main debate is 
that WordPress should follow the standards, opening tag must have 
closing tag. If you leave off the closing PHP tag, then you violate this 
principle. I don't think it is logical to compare PHP, which is a 
programming language, to XHTML which is markup. I don't believe there is 
a comparsion, even if markup can be used in PHP. If you think about it 
in the frame of Opcodes, where there isn't any closing PHP tag anyway, 
then I don't think the principle applies.

> Also, people create the wp-config.php file manually, because the
> installation instructions tell them to do so. They don't let WordPress
> create it for them, even though it can. In fact, I pointed out to
> somebody the other day that it was capable of doing this, and they
> were amazed. People who have used WP for years have no idea that it
> could create your wp-config file for you.
>   

I should mention that since I started using WordPress, that I've never 
once read the manual all the way through or at least by the time I did, 
after the third or fourth time of using the automatic wp-config.php 
creator, I knew that it could do so already. I don't believe there are 
many popular PHP applications which don't create the configuration file 
for you. My focus is limited however, but there were never an instance 
where I had to create the configuration file myself. May had to edit a 
few for the Database, but the file was already available.

Jacob Santos


More information about the wp-hackers mailing list