Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-30 Thread Ashley Sheridan
On Sat, 2010-01-30 at 13:02 +1100, clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 10:02:56 -0500, rob...@interjinn.com (Robert Cummings) wrote: I don't know what you guys are doing wrong but the following should be the correct behaviour: ?php function get_memory( $init=false )

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-29 Thread clancy_1
On Thu, 28 Jan 2010 10:02:56 -0500, rob...@interjinn.com (Robert Cummings) wrote: I don't know what you guys are doing wrong but the following should be the correct behaviour: ?php function get_memory( $init=false ) { static $base = null; if( $base === null || $init ) {

RE: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-28 Thread Ford, Mike
-Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements, possibly hitting the

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-28 Thread Rene Veerman
Thanks for your research Mike, i'm a bit puzzled. I have a custom random-array generator that i use to fill the available memory to it's max, about 1.5G on a 2G system, then passing it to a recursive json string generator. Not passing by reference did double my memory requirements, but i've

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-28 Thread Nathan Rixham
Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory requirements,

RE: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-28 Thread Ford, Mike
-Original Message- From: Nathan Rixham [mailto:nrix...@gmail.com] Sent: 28 January 2010 13:43 Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-28 Thread Robert Cummings
Nathan Rixham wrote: Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to do so can double your memory

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-28 Thread Paul M Foster
On Thu, Jan 28, 2010 at 11:41:43AM -, Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference; failing to

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-28 Thread Robert Cummings
Paul M Foster wrote: On Thu, Jan 28, 2010 at 11:41:43AM -, Ford, Mike wrote: -Original Message- From: Rene Veerman [mailto:rene7...@gmail.com] Sent: 27 January 2010 22:46 And if your script needs to pass large ( 5Mb) arrays around to functions, be sure to use passing-by-reference;

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Ashley Sheridan
On Wed, 2010-01-27 at 10:42 -0500, Paul M Foster wrote: ... should be obvious - but are often overlooked - points within coding practice that can cause the programmer to develop bad habits and bad code. - Dan Brown Tip #1: Don't use count() in loops unless there are very few items to

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Michael A. Peters
Paul M Foster wrote: ... should be obvious - but are often overlooked - points within coding practice that can cause the programmer to develop bad habits and bad code. - Dan Brown Tip #1: Don't use count() in loops unless there are very few items to count and performance doesn't matter, or the

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Ashley Sheridan
On Wed, 2010-01-27 at 08:01 -0800, Michael A. Peters wrote: Paul M Foster wrote: ... should be obvious - but are often overlooked - points within coding practice that can cause the programmer to develop bad habits and bad code. - Dan Brown Tip #1: Don't use count() in loops

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Eric Lee
On Wed, Jan 27, 2010 at 11:44 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2010-01-27 at 10:42 -0500, Paul M Foster wrote: ... should be obvious - but are often overlooked - points within coding practice that can cause the programmer to develop bad habits and bad code. -

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Ashley Sheridan
On Thu, 2010-01-28 at 00:08 +0800, Eric Lee wrote: On Wed, Jan 27, 2010 at 11:44 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2010-01-27 at 10:42 -0500, Paul M Foster wrote: ... should be obvious - but are often overlooked - points within coding practice that can

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Richard Quadling
2010/1/27 Michael A. Peters mpet...@mac.com: Paul M Foster wrote: ... should be obvious - but are often overlooked - points within coding practice that can cause the programmer to develop bad habits and bad code. - Dan Brown Tip #1: Don't use count() in loops unless there are very few

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Michael A. Peters
Richard Quadling wrote: for ($i = 0, $j = count($a) ; $i $j ; ++$i) { } is a very common way to handle that. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Richard Quadling
2010/1/27 Richard Quadling rquadl...@googlemail.com: 2010/1/27 Michael A. Peters mpet...@mac.com: Paul M Foster wrote: ... should be obvious - but are often overlooked - points within coding practice that can cause the programmer to develop bad habits and bad code. - Dan Brown Tip #1:

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Daniel Egeberg
On Wed, Jan 27, 2010 at 16:44, Ashley Sheridan a...@ashleysheridan.co.uk wrote: What about using the right type of quotation marks for output: I use double quotes() if I expect to output variables within the string, and single quotes when it's just a simple string. It's only a general rule

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Daniel Brown
On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg degeb...@php.net wrote: There is virtually no difference nowadays. It's a long time since anything like that has mattered. Actually, that's not true enough to be dismissive. It depends on several factors. -- /Daniel P. Brown

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Daniel Egeberg
On Wed, Jan 27, 2010 at 18:13, Daniel Brown danbr...@php.net wrote: On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg degeb...@php.net wrote: There is virtually no difference nowadays. It's a long time since anything like that has mattered.    Actually, that's not true enough to be dismissive.  

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Ashley Sheridan
On Wed, 2010-01-27 at 18:26 +0100, Daniel Egeberg wrote: On Wed, Jan 27, 2010 at 18:13, Daniel Brown danbr...@php.net wrote: On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg degeb...@php.net wrote: There is virtually no difference nowadays. It's a long time since anything like that has

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Daniel Brown
On Wed, Jan 27, 2010 at 12:26, Daniel Egeberg degeb...@php.net wrote: Well, I would still say it's far too insignificant to bother with. And for the most part, you'd be right but it still isn't good practice to *not* teach something strictly because it's not entirely significant.

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Robert Cummings
Ashley Sheridan wrote: On Wed, 2010-01-27 at 18:26 +0100, Daniel Egeberg wrote: On Wed, Jan 27, 2010 at 18:13, Daniel Brown danbr...@php.net wrote: On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg degeb...@php.net wrote: There is virtually no difference nowadays. It's a long time since anything

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Daniel Brown
On Wed, Jan 27, 2010 at 12:27, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Depends I guess on how far you need to optimise the code. I'd imagine that to something like Facebook, every split-second of optimisation is worth it, as even a 100th of a second becomes minutes of wasted time

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Robert Cummings
Daniel Brown wrote: On Wed, Jan 27, 2010 at 12:27, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Depends I guess on how far you need to optimise the code. I'd imagine that to something like Facebook, every split-second of optimisation is worth it, as even a 100th of a second becomes

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Rene Veerman
I'd like to add that when dealing with large memory structures, usually arrays, combining them is fastest when done like this: $array1 += $array2; This will not always produce correct results when dealing with arrays that contain identical keys, but for non-overlapping arrays it is far faster

Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Nathan Rixham
Daniel Egeberg wrote: On Wed, Jan 27, 2010 at 18:13, Daniel Brown danbr...@php.net wrote: On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg degeb...@php.net wrote: There is virtually no difference nowadays. It's a long time since anything like that has mattered. Actually, that's not true