Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #15600

Re: Refresher for array handling???

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.php
Subject Re: Refresher for array handling???
Date 2015-07-21 09:07 +0200
Organization PointedEars Software (PES)
Message-ID <1699924.HXGEyF5x7g@PointedEars.de> (permalink)
References <lvbaqa189n0e1ldtgg1de1vprbjvs46es2@4ax.com> <55a6598d$0$2914$e4fe514c@news2.news.xs4all.nl> <239530657.1smQKY0v18@PointedEars.de> <55ad0600$0$2900$e4fe514c@news2.news.xs4all.nl> <mok5lk$cqi$2@dont-email.me>

Show all headers | View raw


Denis McMahon wrote:

> On Mon, 20 Jul 2015 16:30:27 +0200, Erwin Moller wrote:
>> On 7/17/2015 9:24 PM, Thomas 'PointedEars' Lahn wrote:
>>> Erwin Moller wrote:
>>>> ?>
>>> 
>>> Avoid this in PHP programs unless you are sure that you want what
>>> follows to be sent to the standard output.
> 
>> I don't agree with that attitude.
>> Leaving out ?> at the end is one of the worst ideas PHP ever came up
>> with, and I won't support it.
> 
> This is a matter of personal preference.

It is insofar that it shows whether you have the preferences of a PHP 
amateur.  There are important implications if you write it in the *wrong* 
place, such as at the *supposed* end of library code, that may not be easy 
to debug.  PHP means “PHP Hypertext Preprocessor” (now).  Whitespace (space, 
tab, newline, etc.) outside of <?…?> that is not obviously visible is made 
*output* in PHP, and once output has been sent, you not only have whitespace 
in the output but also cannot send HTTP headers anymore 
(<http://php.net/header>).

Meaning that files dynamically generated with PHP are sent with the default 
“Content-type: text/html” even if the resource content is not HTML, which 
breaks downloads, generated or proxy-fetched images, compacted resources, 
and so on.  And if the content is HTML, it is very easy to force 
Quirks/Compatibilty Mode because the DOCTYPE declaration may not be on the 
first line anymore.

> I agree that if you're writing php and don't understand what '?>' means, 
> you shouldn't be writing php.

Yes, but that is missing the point here completely.  Again.

> Listen to people are willing to explain the real benefits to them of their 
> preferred coding style, because they are the ones who might have something 
> you can learn, not the ones who just state "this is how it must be done".

If you cared to read, which *again* you did _not_, there *were* explanations 
in my posting, and I did _not_ say that “this is how it must be done” but 
gave well-founded recommendations, now elaborated on here.

> But whether you always terminate code with it or not is down to your
> personal style (unless your employer has a house style).

Again, *nobody* has suggested that you either *always* write it or *always* 
omit it.

-- 
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Refresher for array handling??? bobmct <r.mariotti@fdcx.net> - 2015-07-14 12:12 -0400
  Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-15 15:01 +0200
    Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-15 15:03 +0200
    Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-17 21:24 +0200
      Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-20 16:30 +0200
        Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-20 19:45 +0200
          Re: Refresher for array handling??? Matthew Carter <m@ahungry.com> - 2015-07-20 22:36 -0400
          Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-21 11:22 +0200
            Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-21 13:30 +0200
              Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-21 14:03 +0200
        Re: Refresher for array handling??? Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-21 01:01 +0000
          Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-21 09:07 +0200
  Re: Refresher for array handling??? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-07-15 20:18 +0200
  Re: Refresher for array handling??? Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-17 02:51 +0000

csiph-web