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: > > > > > > >function get_memory( $init=

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: > > >function get_memory( $init=false ) >{ > static $base = null; > if( $base === null || $init ) > { >

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-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;

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

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 (>

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 requir

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 change

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 hitti

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

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

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

2010-01-27 Thread Nathan Rixham
Richard Quadling wrote: > 2010/1/27 Richard Quadling : >> 2010/1/27 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

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 wrote: >> On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg 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. I

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 tha

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 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 over t

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

2010-01-27 Thread Daniel Brown
On Wed, Jan 27, 2010 at 12:27, Ashley Sheridan 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 over the course of a >

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 wrote: On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg wrote: There is virtually no difference nowadays. It's a long time since anything like that has mattered. Actu

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

2010-01-27 Thread Daniel Brown
On Wed, Jan 27, 2010 at 12:26, Daniel Egeberg 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. For example, pol

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 wrote: > > On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg wrote: > >> > >> There is virtually no difference nowadays. It's a long time since > >> anything like that has mattered. > > > >Actu

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

2010-01-27 Thread Daniel Egeberg
On Wed, Jan 27, 2010 at 18:13, Daniel Brown wrote: > On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg 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

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

2010-01-27 Thread Daniel Brown
On Wed, Jan 27, 2010 at 12:08, Daniel Egeberg 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.br...@parasane.net || danbr...@php.net

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

2010-01-27 Thread Daniel Egeberg
On Wed, Jan 27, 2010 at 16:44, Ashley Sheridan 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 of thumb and should

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

2010-01-27 Thread Richard Quadling
2010/1/27 Richard Quadling : > 2010/1/27 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 cou

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 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

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 > wrote: > > > 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 progra

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 wrote: > 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 > > > >

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(

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 th

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 item

[PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Paul M Foster
"... 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 number will vary over