 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
06-16-2009, 10:44 AM
|
#1 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Do you end your PHP documents with "?>"?
Zend actually recommend that you don't place the ending PHP tag ?> because that way it prevents any white-spacing creeping in after you've ended the ?> tag.
I think we've all experienced that problem before. Usually the first thing to detect a white-space is the session class, which is unable to work when output has been started because the session class wishes to send HTTP headers. Often is the case that your document is as follows, and you spend all your time trying to find the white-space:
"?> "
Quite a few IDEs now will actually trim the document before saving and thus eliminating that issue. With Zend's recommendations, however, I can only feel one way at the moment, and that my document seems incomplete without the closing PHP tag.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
06-16-2009, 10:45 AM
|
#2 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
I got into the habit of leaving it out, in fact it became part of the coding standards at work.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
06-16-2009, 11:02 AM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
I also leave out the closing PHP tag at the end of files, to me it seems a redundant extra line to include it.
|
|
|
|
06-16-2009, 11:22 AM
|
#4 (permalink)
|
|
The Acquainted
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
|
Never heard of this before, but I am still fairly new to PHP. To me, I don't think I could leave it out. I like everything to match up to its rightful partner, and leaving a ?> off the end of the file would be like walking with one leg.
|
|
|
06-16-2009, 02:55 PM
|
#5 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
I started leaving it out after I wrote my application in an old IDE and I had white space errors on all the files.
|
|
|
|
06-16-2009, 03:06 PM
|
#6 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
I never add the PHP ending tag at the end of files...can cause alot of trouble, learned that lesson :)
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|
06-16-2009, 03:50 PM
|
#7 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
I never add it.
__________________
|
|
|
|
06-16-2009, 05:01 PM
|
#8 (permalink)
|
|
The Contributor
Join Date: May 2009
Posts: 53
Thanks: 2
|
I learned to never add it as well. :)
|
|
|
06-16-2009, 05:17 PM
|
#9 (permalink)
|
|
The Acquainted
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
|
I've just learnt my new thing for the day. Will have to get used to the feeling of walking with a leg missing
Thanks 
|
|
|
06-16-2009, 11:36 PM
|
#10 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
I use it some times and some times i don't ;)
|
|
|
|
06-17-2009, 12:22 AM
|
#11 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Consistent then Codefreek 
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
06-17-2009, 01:05 AM
|
#12 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
Yeah ;), one thing that came to mind you could just write a function, to check for whitespace ?, Can't you do that..
|
|
|
|
06-17-2009, 01:33 AM
|
#13 (permalink)
|
|
The Acquainted
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
|
I like to have it there for personal reasons, just makes it easier to find the end of the document.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
|
|
|
06-17-2009, 01:39 AM
|
#14 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Sure you could write a function, or just miss the ending tag out.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
06-17-2009, 08:55 AM
|
#15 (permalink)
|
|
The Contributor
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
|
Are we talking about like a functions file? I put it just to be safe...
|
|
|
06-17-2009, 12:05 PM
|
#16 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by Randy
I like to have it there for personal reasons, just makes it easier to find the end of the document.
|
I usually do like:
PHP Code:
// End of File.php
in the end, and that way I can easially find the end of it(apart from the obvious way of scrolling to the bottom of the file xD).
Quote:
Originally Posted by rguy84
Are we talking about like a functions file? I put it just to be safe...
|
We're talking about any PHP-file.
Though, I only use classfiles nowadays, 'cause I'm using my framework which applies the MVC-structure, so basicly, all files are classes. Except helpers and view-files.
__________________
|
|
|
|
06-17-2009, 06:10 PM
|
#17 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by Tanax
I usually do like:
PHP Code:
// End of File.php
|
I find that the End key (windows) or Command-Down (mac) work well to find the end of a file. Do people really need some sort of visual confirmation that yes, indeed, they've reached the end of a file? 
|
|
|
|
06-17-2009, 06:53 PM
|
#18 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
Quote:
Originally Posted by Salathe
I find that the End key (windows) or Command-Down (mac) work well to find the end of a file. Do people really need some sort of visual confirmation that yes, indeed, they've reached the end of a file? 
|
Is getting to the end of a file not a visual confirmation as well?
|
|
|
|
06-17-2009, 11:44 PM
|
#19 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by adamdecaf
Is getting to the end of a file not a visual confirmation as well?
|
Absolutely, that's the point my post was making. When walking to the end of the earth, there doesn't need to be any sign warning about coming to the end of the earth, it just ends! (Assuming of course, that the world is flat.  )
|
|
|
|
06-17-2009, 07:24 PM
|
#20 (permalink)
|
|
The Contributor
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
|
Quote:
Originally Posted by Tanax
We're talking about any PHP-file.
Though, I only use classfiles nowadays, 'cause I'm using my framework which applies the MVC-structure, so basicly, all files are classes. Except helpers and view-files.
|
Ah ok. Sadly I am not at full application development yet, so I don't use classes.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|