TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Do you end your PHP documents with "?>"? (http://www.talkphp.com/general/4562-do-you-end-your-php-documents.html)

Wildhoney 06-16-2009 10:44 AM

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.

sketchMedia 06-16-2009 10:45 AM

I got into the habit of leaving it out, in fact it became part of the coding standards at work.

Salathe 06-16-2009 11:02 AM

I also leave out the closing PHP tag at the end of files, to me it seems a redundant extra line to include it.

Hightower 06-16-2009 11:22 AM

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.

Enfernikus 06-16-2009 02:55 PM

I started leaving it out after I wrote my application in an old IDE and I had white space errors on all the files.

xenon 06-16-2009 03:06 PM

I never add the PHP ending tag at the end of files...can cause alot of trouble, learned that lesson :)

Tanax 06-16-2009 03:50 PM

I never add it.

Sirupsen 06-16-2009 05:01 PM

I learned to never add it as well. :)

Hightower 06-16-2009 05:17 PM

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 ;-)

codefreek 06-16-2009 11:36 PM

I use it some times and some times i don't ;)

Wildhoney 06-17-2009 12:22 AM

Consistent then Codefreek :-)

codefreek 06-17-2009 01:05 AM

Yeah ;), one thing that came to mind you could just write a function, to check for whitespace ?, Can't you do that..

Randy 06-17-2009 01:33 AM

I like to have it there for personal reasons, just makes it easier to find the end of the document.

Wildhoney 06-17-2009 01:39 AM

Sure you could write a function, or just miss the ending tag out.

rguy84 06-17-2009 08:55 AM

Are we talking about like a functions file? I put it just to be safe...

Tanax 06-17-2009 12:05 PM

Quote:

Originally Posted by Randy (Post 25562)
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 (Post 25572)
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.

Jim 06-17-2009 05:38 PM

I never had problems with it so yeah, i still place it there... Don't know why though, i know it can give me problems

Salathe 06-17-2009 06:10 PM

Quote:

Originally Posted by Tanax (Post 25576)
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? :-/

adamdecaf 06-17-2009 06:53 PM

Quote:

Originally Posted by Salathe (Post 25587)
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?

rguy84 06-17-2009 07:24 PM

Quote:

Originally Posted by Tanax (Post 25576)
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.


All times are GMT. The time now is 11:34 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0