Re: Help with a home-grown function

From: Date: Tue, 26 Jul 2005 11:47:30 +0000
Subject: Re: Help with a home-grown function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-219342@lists.php.net to get a copy of this message
* "Ford, Mike" <M.Ford@leedsmet.ac.uk> : > On 21 July 2005 22:19, Chris W. Parker wrote: > > > 2. It will be a good idea to get out of the habit of breaking in and > > out of PHP like that. Instead just do: echo 'hi1'; > > Why? Some of us just strongly prefer the breaking in and out style -- I use > it almost exclusively. In my 10,000s of lines of code, you can probably > count the number of echos on your fingers! > > > You'll have problems down the road with modifying the headers > > (cookies, redirects, content-type, etc.) if you break in and out. > > Absolute rubbish -- whatever gives you this idea? The sequence > > ?> x<?php > > Is functionally identical to > > echo 'x'; > > so anything that works with the latter will work identically with the > former. I disagree with both statements. Echoing and breaking out of PHP are typically both undesirable in large applications where you may wish to change headers. Capture your output into a variable and send it to output once all processing is done. This may be done using output buffering or other techniques. -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/

« previous php.general (#219342) next »