Closing php tags (?>) are not required when they are at the end of file. There are multiple reasons to not have them:
1. No worries about outputting whitespace before headers by accident.
2. At least the 'patch' utility adds newline at end of file when applying patches.
3. Various utilities such as sed add newline at end of file, when php files are processed with them.
4. Diffs without newlines at end of file have an additional line stating the absence of newline.
There are several posts on the net advocating against using closing php tags:
http://phpstarter.net/2009/01/omit-the-php-closing-tag/
http://choosetheforce.blogspot.com/2008 ... p-tag.html
Zend Framework prohibits closing php tags.
I propose removing all closing php tags at the ends of php files immediately.
Drop php closing tags
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Re: Drop php closing tags
Yes I'd like to see this changed I'm not sure about 3.0 but having to configure editors to drop the end new line is a PITA and not actually required by PHP it's any subsequent new lines that cause problems. I'm not sure if we'll do this in 3.0 but it'd be a bigger pain to have 3.1 and 3.0 using different end of file standards imo so I'd advocate to do this for 3.0.8 the only problem is it would mean every single file is modified.
Re: Drop php closing tags
Are you referring to modifications in source control or release packages?
The former is I think a moot point, since changes are going to be at the very end they should be unlikely to conflict with anything.
The latter has already happened with 3.0.7-pl1, which changed every single php file due to dropping svn keywords, and that was a patch release.
The former is I think a moot point, since changes are going to be at the very end they should be unlikely to conflict with anything.
The latter has already happened with 3.0.7-pl1, which changed every single php file due to dropping svn keywords, and that was a patch release.
- A_Jelly_Doughnut
- Registered User
- Posts: 1780
- Joined: Wed Jun 04, 2003 4:23 pm
Re: Drop php closing tags
First, all other things being equal, I would say that it is absurd to open a "tag" and not close it. But, as pointed out, various tools wrongly add new lines to the end of a file, which can cause problems once in a great while.
If I ruled the world, I'd leave phpBB as it is and tell GNU to fix their tools. Rule the world I do not, so altering phpBB as a solution to the problem is acceptable. However, as discussed previously, it cannot happen for 3.0.x because MODs rely on finding ?>
(whereas the $Id$ keyword was completely ignored as a practical manner)
If I ruled the world, I'd leave phpBB as it is and tell GNU to fix their tools. Rule the world I do not, so altering phpBB as a solution to the problem is acceptable. However, as discussed previously, it cannot happen for 3.0.x because MODs rely on finding ?>
(whereas the $Id$ keyword was completely ignored as a practical manner)
A_Jelly_Doughnut
Re: Drop php closing tags
GNU tools aren't broken. In PHP "?>\n" works absolutely fine, and it's the customary way for any file to end with a new line. The problem arises when you add anything, even another new line, after that last new line. Hence we trim all white space off, as a kind of over zealous paranoia. It's really annoying imo as most non PHP tools don't usually work like that.A_Jelly_Doughnut wrote:If I ruled the world, I'd leave phpBB as it is and tell GNU to fix their tools. Rule the world I do not, so altering phpBB as a solution to the problem is acceptable. However, as discussed previously, it cannot happen for 3.0.x because MODs rely on finding ?>
Re: Drop php closing tags
I am in favor of dropping the closing tag. I'd also like to see a newline at the end of every file, since many editors (VIM) add this by default, and any unix-like environment expects it.
However, I don't think changing this in 3.0 is a good idea, for following reason mentioned by Josh:
However, I don't think changing this in 3.0 is a good idea, for following reason mentioned by Josh:
Changing it for 3.1 would seems like a good idea to me. MODX/AutoMOD would need to be adjusted to support finding the end-of-file, but that should be trivial.A_Jelly_Doughnut wrote:it cannot happen for 3.0.x because MODs rely on finding ?>
- imkingdavid
- Registered User
- Posts: 1050
- Joined: Thu Jul 30, 2009 12:06 pm
Re: Drop php closing tags
I agree with this; I have seen MODs that look for ?> because that will always occur in the file and allow the FIND to work. But I think it wouldn't hurt to do this for 3.1 and onward.eviL3 wrote:I am in favor of dropping the closing tag. I'd also like to see a newline at the end of every file, since many editors (VIM) add this by default, and any unix-like environment expects it.
However, I don't think changing this in 3.0 is a good idea, for following reason mentioned by Josh:Changing it for 3.1 would seems like a good idea to me. MODX/AutoMOD would need to be adjusted to support finding the end-of-file, but that should be trivial.A_Jelly_Doughnut wrote:it cannot happen for 3.0.x because MODs rely on finding ?>
Re: Drop php closing tags
I agree with evil. Its good idea but MODs and hacks and code snippets use the ?> to use in the FIND in MODs
Formerly known as Unknown Bliss
No unsolicited PMs please except for quotes.psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
Re: Drop php closing tags
A huge amount of MODs depends on this in the language files. I don't think phpBB 3.0 MODs will be able to install on phpBB 3.1 directly in the first place. So if we simply drop the tags, adjust MODX to support going to end-of-file and provide a conversion script (for MODs from 3.0 to 3.1), that script could simply convert all "find ?>" actions to "find eof".
An alternative solution would be to have the 3.1 AutoMOD and MODX XSL adjusted so they display "find ?>" as "find eof".
I personally would prefer the first solution. Please comment quickly, so I can update the ticket with the according subtasks.
An alternative solution would be to have the 3.1 AutoMOD and MODX XSL adjusted so they display "find ?>" as "find eof".
I personally would prefer the first solution. Please comment quickly, so I can update the ticket with the according subtasks.
- nickvergessen
- Former Team Member
- Posts: 733
- Joined: Sun Oct 07, 2007 11:54 am
- Location: Stuttgart, Germany
- Contact:
Re: Drop php closing tags
That would be really odd, as there are some files which contain more than one ?>eviL3 wrote:An alternative solution would be to have the 3.1 AutoMOD and MODX XSL adjusted so they display "find ?>" as "find eof".
Member of the Development-Team — No Support via PM