I am using gethostbyname() to get the ip address of domains in an application.
In some cases invalid addresses like '50.9.49' are checked also.
echo gethostbyname('50.9.49'); // returns 50.9.0.49
In this cases gethostbyname should return false or the unmodified invalid ip address. however the functions returns the modified IP address 50.9.0.49.
Looks like a bug in php. The quick fix seems to be to check for invalid numerical addresses before, are there any other suggestions?
PHP's
gethostbynameactually uses the results of the underlying OS'sgethostbyname, e.g., from Linux'snetdb.hor Windows'Winsock2.h. It's those functions that actually produce the return value, not PHP.