SitePoint Sponsor

User Tag List

View Poll Results: Do you?

Voters
78. You may not vote on this poll
  • Yes

    70 89.74%
  • No

    4 5.13%
  • I didn't know you could do that!

    4 5.13%
Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 54
  1. #26
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nsj
    Is there a standard?
    Yeah. Your file should end with the closing PHP tag and a new line. I can understand the closing tag (which is logical), but that new line seems just ridiculous.

    I close with a PHP tag and nothing more. That's like putting a space at the end of each line. I can't be bothered with all that extra work that triggers my OCD.

  2. #27
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Brooklyn, NY
    Posts
    359
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Young Twig
    Who came up with this stupid idea? A blank line at the end of the file pisses me off. That is a waste.
    I agree that it seems unnecessary, but that's the convention. EOF is supposed to be on a line all by itself, not at the end of a line with meaningful data. This is a file convention and not specific to any particular language.

    I'm not aware of any software that can't handle a file where EOF is at the end of a line, but you never know. I know some editors that add the newline but hide it from the interface (e.g., you can't highlight the newline before the EOF), so you might be following the convention without realizing it.

    Anyway, what annoys me is that it seems trivial for PHP to strip a newline only when it encounters a closing PHP tag followed by a newline followed by EOF. As it is, all newlines following a closing PHP tag are stripped, and that just screws up my formatting. :-)
    Chris Shiflett
    http://shiflett.org/

  3. #28
    SitePoint Addict
    Join Date
    May 2005
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never close them anymore. One "headers already sent" too many pushed me over the edge.

  4. #29
    SitePoint Addict
    Join Date
    May 2005
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Quaint
    It's just plainly absurd not to use them ?!?!

    "Why bother??", why bother writing good code at all? Why not forget about indenting, commenting, etc...

    Writing GOOD code is about writing maintainable code. A lot of PHP programmers tend to forget this! Whereas for instance Java/C++ programmers are always 'aware' of what they are doing, a lot of PHP programmers just put stuff in their program untill it works and don't care about the correctness of their code..
    In this case you would be wrong. The ability to leave off the closing tag is by design, intentional, and specifically exists to avoid problems with output (whitespace after the closing php tag) appearing when you don't want it. Leaving it off is neither "bad design" nor "unmaintainable".

    Go through the internals list. This very topic was brought up within the last 90 days.

  5. #30
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by someonewhois
    Now, find someone who calls functions as "function(arguments)" but if statements as "if (expression)" (with a space). That'll a little more rare.
    I do that.

    I always put a space between a language construct (like if, while, return) and a following expression.
    Birnam wood is come to Dunsinane

  6. #31
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Young Twig
    Why would you open the tag either?
    Because you have to open it to signify you're using PHP and not just directly outputting content. There's a huge difference. There's NO need to add the closing tag. It serves absolutely zero purpose.

    If you've ever used CPanel, back in the day (over a year ago) the built-in text editor added ~10 new lines at the end of each file (I haven't used the editor in years, so I can't tell you whether they've fixed it or not since then) for no reason. If I were to have an include class that had a closing ?>, I would've run into errors when I went sending headers for previous output. I'm not saying this is why I don't use a ?>, I'm just saying that's a scenario where not having the ?> is actually beneficial.

    Quote Originally Posted by mwolfe
    same thing with c. why the hell do they need a blank line at the end of a file is beyond me.. i'm sure there is some reason for it though.
    Quote Originally Posted by Young Twig
    Heh... That brings up another point. According to PEAR standards, you should have a blank line at the end of all of your files (after that closing tag, of course ). I've also had a C++ compiler spit at me once when I didn't leave a blank line at the end of the file. (I never touched C++ again, by the way.)

    Who came up with this stupid idea? A blank line at the end of the file pisses me off. That is a waste.
    I've used Dev C++, Borland C++, GCC, and MSVC6 and I have NEVER had this warning come up. Now while I have never looked into a C compiler, I can give an educated guess that back in the 70s one of the inventors wrote their parser to read the file and for some reason had the parser stop when it came to a blank space, for whatever technological limitations. Some people (ie. the Visual Basic developers) think it's absolutely ridiculous that we use semicolons in C, PHP, etc., yet we do.

    I seriously don't understand how you complain about hitting enter, but you willingly use the "?>". I really do not see how this is any different. It's part of the language, and according to you they're both 100% necessary.

    Quote Originally Posted by Quaint
    It's just plainly absurd not to use them ?!?!

    "Why bother??", why bother writing good code at all? Why not forget about indenting, commenting, etc...

    Writing GOOD code is about writing maintainable code. A lot of PHP programmers tend to forget this! Whereas for instance Java/C++ programmers are always 'aware' of what they are doing, a lot of PHP programmers just put stuff in their program untill it works and don't care about the correctness of their code..
    Once again, leaving off ?> had no functional implications. Not writing code at all does.

    I hardly see how adding "?>" makes your code more maintainable. Leaving comments off, or indenting, makes the code harder to follow. Leaving a "?>" off at the end of the file will not send you into a circle of confusion. There's a severe difference between

  7. #32
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by someonewhois
    Because you have to open it to signify you're using PHP and not just directly outputting content. There's a huge difference. There's NO need to add the closing tag. It serves absolutely zero purpose.
    I know. You can't leave out the opening tag when including your class, so why leave out the closing one? I see it as uniformity.

    Quote Originally Posted by someonewhois
    I've used Dev C++, Borland C++, GCC, and MSVC6 and I have NEVER had this warning come up.
    I don't remember what I used. But it wouldn't compile without that stupid blank line.

    Quote Originally Posted by someonewhois
    Some people (ie. the Visual Basic developers) think it's absolutely ridiculous that we use semicolons in C, PHP, etc., yet we do.
    It allows for multiple-line statements, right? You can't pull any of that
    Code:
    Array
    (
         0 => 5.2
         1 => 4.9
    );
    crap in Javascript.

    Quote Originally Posted by someonewhois
    I seriously don't understand how you complain about hitting enter, but you willingly use the "?>". I really do not see how this is any different. It's part of the language, and according to you they're both 100% necessary.
    Honestly, I could care less about the coding format standards. I format my code in ways that make it easy for me (and maybe others) to read. I like things to make sense and be uniform (meaning I open and close PHP tags). I also format it in ways that I think look good. The blank line at the end of the file is, to me, ugly. It also triggers my OCD.

    Quote Originally Posted by AutisticCuckoo
    I do that.

    I always put a space between a language construct (like if, while, return) and a following expression.
    Nathan only puts it after if, though. While, for, and foreach all have no spaces before the parentheses.

  8. #33
    SitePoint Evangelist Jedi007's Avatar
    Join Date
    Aug 2005
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you know if you dont close your php tags. the Nighthawks will hack you.
    Oooooo!

    Look how far this topic has gone...

  9. #34
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never have the closing ?>

    For pedantic people who miss their closure, I use

    #?>

    instead

    The reason as others have mentioned is to prevent unintentional whitespace issues.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  10. #35
    SitePoint Evangelist Daijoubu's Avatar
    Join Date
    Oct 2002
    Location
    Canada QC
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What question is this, if you open your zipper, do you close it? OF COURSE I DO :P
    Speed & scalability in mind...
    If you find my reply helpful, fell free to give me a point

  11. #36
    Thinking! Lord Brar's Avatar
    Join Date
    Jun 2004
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Old habits die hard... yes, I do close all the tags that I open.

  12. #37
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Cool

    I close it always, it can be termed as the bad habit of coming from the ASP & JSP background where you don't have that luxury(as far as I know)!!


    Quote Originally Posted by someonewhois
    Anyway, I guess I'm the only one who doesn't bother adding the ?>. It's always seemed like a waste.
    for that statement, you deserve the "PHP Guru of the Year" award taken away from you!!

    btw, you are not the only nutter who doesn't close PHP delimiters!! there are lot of perverts like you!!


    Quote Originally Posted by someonewhois
    Now, find someone who calls functions as "function(arguments)" but if statements as "if (expression)" (with a space). That'll a little more rare.
    well, I do it vice versa. that is, I use "function (arguments)" & "if(condition)"!!


    Quote Originally Posted by Etnu
    I never close them anymore. One "headers already sent" too many pushed me over the edge.
    what's the closing delimiter got to do with it? it occurs because of a whitespace or a line after the closing delimiter!!
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  13. #38
    SitePoint Member My-Proxy's Avatar
    Join Date
    Nov 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your code will confuse if you didn't use "?>" thought the function is correct.
    My-Proxy - The source of your daily fresh proxies.
    Forum Proxy Leecher - Fresh proxies when you need.
    My-Proxy Forum - The place we share daily fresh proxies.
    FPL Leech List - The rank of proxy sites and forums.

  14. #39
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And what about "cat one.php two.php > new.php"?

  15. #40
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to be different, I close my PHP tags like this :

    PHP Code:


  16. #41
    SitePoint Addict devil cat's Avatar
    Join Date
    Apr 2003
    Location
    Reno
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I always close my php pages with ?>. Never knew it was unnecessary until I went back and rewrote some of my old pages and saw that it was missing. Just about had an attack that I would forget something like that, before I realized it still worked.

    But I still close them all that way.

  17. #42
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Brooklyn, NY
    Posts
    359
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by asp_funda
    What's the closing delimiter got to do with it? It occurs because of a whitespace or a line after the closing delimiter!!
    Actually, it doesn't occur because of a newline after a closing tag, because those are stripped.

    In fact, this behavior (which I find annoying) supposedly exists so that people can end a file with a closing tag, newline, then EOF. I find it annoying that this one edge case interferes with every other use of a closing tag:

    http://shiflett.org/archive/151
    Chris Shiflett
    http://shiflett.org/

  18. #43
    SitePoint Enthusiast Joel Farris's Avatar
    Join Date
    Jul 2004
    Location
    Nashville, TN
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Young Twig
    I know. You can't leave out the opening tag when including your class, so why leave out the closing one? I see it as uniformity.
    I look at it like a pair of bookends. If you place a bookend on the left-end of your bookshelf, the books wont fall off that side. BUT, it you fail to place a bookend on the right-end of your bookshelf, the code, err, books could fall off and break.
    <!-- Joel Farris -->
    "I woulda brought my printer to this meeting,
    but they wouldn't allow any Sharp objects on the plane!"

  19. #44
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Joel Farris
    I look at it like a pair of bookends. If you place a bookend on the left-end of your bookshelf, the books wont fall off that side. BUT, it you fail to place a bookend on the right-end of your bookshelf, the code, err, books could fall off and break.
    Except the other side of the bookshelf butts up against a wall called EOF
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  20. #45
    SitePoint Evangelist -Oz-'s Avatar
    Join Date
    Nov 2001
    Location
    Phoenix, AZ, USA
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i definitely close.
    Oz
    GamersMark - On Target Gaming
    OzTheory - Programming and Web Solutions
    AmIBlocked - Check if you've been blocked on IM

  21. #46
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by shiflett
    Although I always close my PHP blocks, there are many expert PHP developers who do not. It's not just a matter of being lazy - it's to avoid superfluous output that might be generated due to have whitespace between the closing PHP tags and the EOF
    That is being lazy... too god damn lazy to take your finger off the return button. You only get header issues if you put whitespace after the closing ?>. Here is a bit of a tip: The whitespace doesn't magically put itself there. After you type the closing tag, then don't freakin' hit the return button more than once and you won't have whitespace issues. And if you are worried you might accidentally hit it twice, then don't flippin' hit it at all. That's what I do

    If you don't want to use them then fine, but don't try to claim some pie in the sky reasoning to justify not being lazy, when that is exactly what you are being by not using them. [yeah you avoid whitespace issues, but only because you can't be bothered to remove your finger from a keyboard button].

  22. #47
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dreamscape
    That is being lazy... too god damn lazy to take your finger off the return button. You only get header issues if you put whitespace after the closing ?>. Here is a bit of a tip: The whitespace doesn't magically put itself there. After you type the closing tag, then don't freakin' hit the return button more than once and you won't have whitespace issues. And if you are worried you might accidentally hit it twice, then don't flippin' hit it at all. That's what I do

    If you don't want to use them then fine, but don't try to claim some pie in the sky reasoning to justify not being lazy, when that is exactly what you are being by not using them. [yeah you avoid whitespace issues, but only because you can't be bothered to remove your finger from a keyboard button].
    The few times I encountered the issue, I attributed it to cut and paste issues rather than directly typing the closing tag, so I find your "too lazy to stop pressing the return key" argument a bit of melodramatic hyperbole.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  23. #48
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good lord! I thought this thread was a joke, but I guess it's real.

    If controlling "white space" is such a big problem... try programming in a strongly typed language / platform that actually forces you to pay careful attention to detail.

  24. #49
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Quote Originally Posted by shiflett
    Actually, it doesn't occur because of a newline after a closing tag, because those are stripped.

    In fact, this behavior (which I find annoying) supposedly exists so that people can end a file with a closing tag, newline, then EOF. I find it annoying that this one edge case interferes with every other use of a closing tag:

    http://shiflett.org/archive/151
    well, that's quite strange, since I used to get the "headers already sent" error when there was a new line after any of the closing delimiters in any of my include files!! once I removed the blank lines after the closing delimiter, I stopped getting the error!!
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  25. #50
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by asp_funda
    well, that's quite strange, since I used to get the "headers already sent" error when there was a new line after any of the closing delimiters in any of my include files!! once I removed the blank lines after the closing delimiter, I stopped getting the error!!
    Because you probably did something that required the headers not to be sent afte ryou included those files. A blank line will begin sending the HTTP 200 OK headers which is too late for cookies and such.

    Just rmeove the lines after your closing tag and it'd be fine.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •