TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-16-2009, 10:44 AM   #1 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Plugin/Addon 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.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-16-2009, 10:45 AM   #2 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

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)
sketchMedia is offline  
Reply With Quote
Old 06-16-2009, 11:02 AM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

I also leave out the closing PHP tag at the end of files, to me it seems a redundant extra line to include it.
Salathe is offline  
Reply With Quote
Old 06-16-2009, 11:22 AM   #4 (permalink)
The Acquainted
 
Hightower's Avatar
 
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
Hightower is on a distinguished road
Default

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.
__________________
Hightower's Softpolio
Send a message via MSN to Hightower
Hightower is offline  
Reply With Quote
Old 06-16-2009, 02:55 PM   #5 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

I started leaving it out after I wrote my application in an old IDE and I had white space errors on all the files.
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Old 06-16-2009, 03:06 PM   #6 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

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.
xenon is offline  
Reply With Quote
Old 06-16-2009, 03:50 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

I never add it.
__________________
Tanax is offline  
Reply With Quote
Old 06-16-2009, 05:01 PM   #8 (permalink)
The Contributor
 
Sirupsen's Avatar
 
Join Date: May 2009
Posts: 53
Thanks: 2
Sirupsen is on a distinguished road
Default

I learned to never add it as well. :)
Send a message via AIM to Sirupsen Send a message via MSN to Sirupsen Send a message via Yahoo to Sirupsen Send a message via Skype™ to Sirupsen
Sirupsen is offline  
Reply With Quote
Old 06-16-2009, 05:17 PM   #9 (permalink)
The Acquainted
 
Hightower's Avatar
 
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
Hightower is on a distinguished road
Default

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
__________________
Hightower's Softpolio
Send a message via MSN to Hightower
Hightower is offline  
Reply With Quote
Old 06-16-2009, 11:36 PM   #10 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

I use it some times and some times i don't ;)
codefreek is offline  
Reply With Quote
Old 06-17-2009, 12:22 AM   #11 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

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.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-17-2009, 01:05 AM   #12 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

Yeah ;), one thing that came to mind you could just write a function, to check for whitespace ?, Can't you do that..
codefreek is offline  
Reply With Quote
Old 06-17-2009, 01:33 AM   #13 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

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
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-17-2009, 01:39 AM   #14 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

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.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-17-2009, 08:55 AM   #15 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

Are we talking about like a functions file? I put it just to be safe...
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 06-17-2009, 12:05 PM   #16 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Randy View Post
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 View Post
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.
__________________
Tanax is offline  
Reply With Quote
Old 06-17-2009, 06:10 PM   #17 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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?
Salathe is offline  
Reply With Quote
Old 06-17-2009, 06:53 PM   #18 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
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?
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 06-17-2009, 11:44 PM   #19 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by adamdecaf View Post
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. )
Salathe is offline  
Reply With Quote
Old 06-17-2009, 07:24 PM   #20 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get PHP 5. to work? Newbie windows PHP guy DotNetTim Absolute Beginners 11 02-01-2013 11:02 AM
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM
what are all the subjects in php? sarmenhb General 7 01-21-2008 05:41 PM
Embeding PHP inside HTML documents Orc General 8 01-18-2008 08:10 PM


All times are GMT. The time now is 02:20 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design