Ive got a strange php gethostbyaddr() problem. A simple page like this:

<? echo gethostbyaddr('') ?> // doesnt work for any ip addr

Takes ages to load via a web browser (i guess dns timing out) it then
just prints the ip addr (indicating failure). If I log into the
webserver ( and do:

$ php -r "echo gethostbyaddr('');" // run php binary

It works fine and gives the correct hostname instantly. Ive checked the
dns setup for our network and everything seems fine.

$ dig -x // gives the right answer

I thought the webserver could be chrooted and hence could not read
resolve.conf to resolve, however if i exec dig in the php script via
the webserver:

<? echo `dig -x` ?>

Then i get the same result as from the shell, indicating it can resolve

The weird thing is if i run the php script through my windows server
then it works straight away (it uses the same dns etc..)

The webserver im having problems with is running FreeBSD 5.2.1, Apache
1.3.29 and PHP 4.3.4.

All I can think of is some differences between the php SAPI module and
binary in terms of how gethostbyaddr works? Could this be the problem or
is there something else that could be wrong?