Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: Check for military time Date: Mon, 2 Nov 2015 18:57:23 +0100 Lines: 98 Message-ID: <5637A403.5030200@arnowelzel.de> References: <1874827.QbCUPLQBcH@PointedEars.de> <562F77B7.1050001@arnowelzel.de> <8737wvd78w.fsf@ahungry.com> <5631e20e$0$23743$e4fe514c@news.xs4all.nl> <87y4elb05f.fsf@ahungry.com> <56375c5b$0$23788$e4fe514c@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: individual.net InMuhDWSumXLjyKbx6/lZQ5wJ4H8D/kOVTg+2sjSL1v5V1Ihhm Cancel-Lock: sha1:/KSSqZzyqlxYsZ33rstiex77+Lk= In-Reply-To: <56375c5b$0$23788$e4fe514c@news.xs4all.nl> Xref: csiph.com comp.lang.php:15839 Erwin Moller schrieb am 2015-11-02 um 13:51: > On 10/30/2015 2:44 AM, Matthew Carter wrote: [...] >> Tell me, in these two sample files, which is easier to debug if the >> aforementioned use cases occurred that cause an error when the file is >> included by another file making use of header responses: >> >> ------------------File One (no closing tag, misplaced HTML)----------- >> > >> function add($a, $b) { >> return $a + $b; >> } >> >>

This is my great page of addition!

>> >> ------------------File Two (closing tag, extra space)----------------- >> > >> function add($a, $b) { >> return $a + $b; >> } >> >> ?> > > > People who include files and put whitespaces after the closing tag will > quickly see the infamous "Output created before headers bla bla, etc > etc." error. This will just happen, if a scripts wants to add headers which is not always the case. > Hmmm, HUGE PROBLEM! Now what? > > We have a few choices: > 1) Remove the offending whitespace, and tell the programmer NOT to do > that again. And hope that he will obey this rule. More likely this will happen again many times. > 2) Change the language, violate the logical assumption that each opening > tag should be accompanied by a closing tag. > > > It is beyond my understanding how anyone can opt for the second option. You will do this, when you first had to spend hours in finding bugs in a system which consist of hundreds of files and some problem shows up caused by unintentional whitespaces. > What is even more flabberghasting is the fact many people are willing to > defend that crazy decision. As already mentioned by T. Lahn: Cite: "The closing ?> tag MUST be omitted from files containing only PHP." [...] > And if some programmer REALLY has trouble avoiding whitespaces after the > closing tag, write some simple bash script, that checks for them. > (I never needed that, but it is easy to write: just match the last ?> > and see if anything follows) Before I create a script to check other scripts I would just omit the closing tag - then I don't need any "check scripts" at all ;-). >> There have been 0 good reasons for including a closing tag (it's just too >> bad we can't actually have a '.phpdef' file type or something that >> simulates a 100% PHP only file, without dropping in and out of tags and >> just avoids the use of the nonsense entirely). >> > > I fail, and keep failing, to see the importance of this. > We programmers have puzzles and problems to be solved daily. > Finding an unintended whitespace isn't really a big part of my daily > business...... > > This solves a problem that didn't have to be solved, and it made the > language uglier. PHP is already ugly in many places. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de http://fahrradzukunft.de