I meant to write about this last week!
I see a LOT of examples on the PHP website, both by contributions and by
the staff responsible for the manual, of using functions inside of loops
to get a value that doesn't change, i.e. the end or beginning of an
array.
A lot of code out there would speed up tremendously if the necessary
value was stored in a temporary variable, which would then be used in
the loop. Probably, using echo() or print() in a loop also slows things
down, buffering into a variable first is much faster, I bet.
One thing I've taken to doing that is related to this, is any object
method() that would normally have a printed output, I make two output
functions, 'getValue()' and 'printValue()'. the getValue() buffers to a
variable in the object and this can be used inline in another place
thats buffering output. If I want it printed right away, the
printValue() calls getValue().
And because I like readable web page HTML, I also have begun to start
including an 'indention' argument to those functions, or sometimes an
'indention' attribute. At the beginning of the buffering and also
following a '\n' in the HTML being buffered, I place the number of
spaces to cause proper indention in the HTML output to make tables etc
line up. It does make the files a little bigger, but it's lot's easier
to see what's going on in the code. I suppose if I wanted to, I could
make a global variable that said, 'INDENTION_ON/OFF' for production.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]