<?php echo '<h1>fsockopen(rest.akismet.com, 80, $errno, $errstr);</h1>'; $r = fsockopen('rest.akismet.com', 80, $errno, $errstr); var_dump($r); var_dump($errno); var_dump($errstr); echo '<h1>fsockopen(google.com, 80, $errno, $errstr);</h1>'; $r = fsockopen('google.com', 80, $errno, $errstr); var_dump($r); var_dump($errno); var_dump($errstr); echo '<h1>gethostbynamel(rest.akismet.com);</h1>'; $t = gethostbynamel('rest.akismet.com'); var_dump($t); echo '<h1>gethostbynamel(google.com);</h1>'; $t = gethostbynamel('google.com'); var_dump($t); ?>
Executing it from shell will work fine. But you must execute it in the Apache Webserver context meaning you need to call the script in your browser calling the server URI via http://YOUR_HOST/YOUR_PATH_TO_SCRIPT/YOUR_SCRIPTNAME.php
Further reading:
- bytes.com php_network_getaddresses: getaddrinfo failed