is_null very slow

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am a newcomer to php; I recently loaded a binary copy (5.0.3) onto my PC
running win2k and Apache 2.0.52.
It seems to work fine except that it is very slow running the function
is_null e.g. the dummy program below -
for($i=0; $i<1000; $i++) {
  if(is_null($x)) $y=0;
echo 'done'
This takes around 30 seconds to run and the disk is accessed continuously.
A friend ran it under both win2k and Linux and it finished in under a
second. Have I set up something wrong? As I say everything else seems fine.
Thanks for any help.
Peter Croft

Re: is_null very slow

On Wed, 8 Jun 2005 22:11:55 +0100, "Peter Croft"

Quoted text here. Click to load it

 That would produce 1000 warnings under a sensible error_reporting

 Perhaps your copy is logging warnings to a file, whereas your friend's has
error reporting disabled entirely.

< Space: disk usage analysis tool

Re: is_null very slow

Thanks - that seems to be the answer.
I see I misunderstood is_null. What I was trying to do was to find which
values in an array had not been assigned to
and then give them a value
(It is more convenient for me to do things this way than to assign default
values to start with.)
for($i=0; $i<1000; $i++) {
  if(is_null($x[$i])) $x[$i]=$i;
I have just read about isset - is that the right way to do it?
To a php-newbie it seems a bit strange that some elements in an array can be
considered undefined whilst others aren't.

Quoted text here. Click to load it

Re: is_null very slow

Following on from Peter Croft's message. . .
Quoted text here. Click to load it

You often find empty building plots in a street.

Some houses are vacant. - $house[67]=0;

Some may not be built or have been demolished.
  - unset($house[45])

PETER FOX Not the same since the e-commerce business came to a .
2 Tees Close, Witham, Essex.
Gravity beer in Essex  <

Re: is_null very slow

Why don't you use isset() or empty() instead then?

Site Timeline