Jay Fitzgerald mailto:[EMAIL PROTECTED]
on Saturday, August 09, 2003 10:05 PM said:
I am a somewhat slow learner in that I cannot learn from reading - the
stuff on functions, for example, is confusing to me - I can only learn
by examples with explanations of why certain things are done.
I
I've never seen a comma concatenation operator in PHP and the
following when cut and paste to a test PHP script generates a parse
error under PHP 4.3.2. Could you elaborate on this operator? Is it part
of the PHP 5 engine? Or are you mistaken in assuming the following works
when perhaps you use
Comparison to a variable is expectedly slower since the engine must
perform a lookup into the running script's variable list. Since a
constant doesn't require a lookup it's access time is O( 1 ) whereas the
lookup of a variable will lie someplace between O( 1 ) and O( lg n )
depending on the
On Mon, 2003-08-11 at 13:29, Chris W. Parker wrote:
* while loop
$ctr = 0;
$val = 0;
while($ctr10)
{
$val++;
$ctr++;
}
** for loop
$val = 0;
for($ctr=0;$ctr10;$ctr++)
{
$val++;
}
I get the following results (very consistently +/- .1) which agrees
Robert Cummings mailto:[EMAIL PROTECTED]
on Monday, August 11, 2003 10:55 AM said:
Or are you mistaken in assuming the
following works when perhaps you use this style as part of an echo
statement normally.
I apologize. I did not copy and paste my the code I used in my test file
into my
I have written an online event registration system and I am curious to
know if there is anyone out there who could either take my code and
optimize it for me or basically help me learn how to optimize my code
off-list. I am a php nub and I know there are probably all kinds of bugs
and duplications
* Thus wrote Ray ([EMAIL PROTECTED]):
so if $a is something like the size of an array or another thing that affects
the number of times the loop needs to be run. then if you can, reverse the
order of the loop so you can compare to 0 (or another constant)
?php
$a = 1000;
$i = $a;
In that case it makes perfect sense since a concatenation is not
actually performed. The loops stuff though might be more tricky to
determine reasoning. I imagine it has to do with the execution tree and
references being created at various stages. Probably the for loop has an
extra step or two
Robert Cummings mailto:[EMAIL PROTECTED]
on Monday, August 11, 2003 11:11 AM said:
$i = 0;
while( $i++ 1000 ){}
[snip]
Notice the large difference when the incrementation occurs within the
while check itself.
Wow, look at that. I had no idea you could even do that. Now my pages
also, if you can compare to a constant, there is a notable difference as well.
?php
$i = 0;
$a = 1000;
while( $i++ $a ){}
?
real0m10.268s
user0m10.000s
sys 0m0.030s
?php
$i = 0;
$a = 1000;
while( $i++ 1000 ){}
?
real0m7.057s
user0m6.880s
sys 0m0.020s
so if
10 matches
Mail list logo