3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function checkdnsrr2($hostName, $recType = '') { if(!empty($hostName)) { if( $recType == '' ) $recType = "MX"; exec("nslookup -type=$recType $hostName", $result); // check each line to find the one that starts with the host // name. If it exists then the function succeeded. foreach ($result as $line) { if(eregi("^$hostName",$line)) { return true; } } // otherwise there was no mail handler for the domain return false; } return false; } if (checkdnsrr('gmail.com')) { echo 'yes'; } else { echo 'no'; } if (checkdnsrr2('gmail.com')) { echo 'yes'; } else { echo 'no'; }
Output for 7.0.14 - 7.1.0
nono
Output for 4.3.11, 5.0.0 - 7.0.10
no Warning: exec(): Unable to fork [nslookup -type=MX gmail.com] in /in/AZrQd on line 6 no
Output for 4.3.2 - 4.3.10, 4.4.0 - 4.4.9
no Warning: exec(): Unable to fork [nslookup -type=MX gmail.com] in /in/AZrQd on line 6 Warning: Invalid argument supplied for foreach() in /in/AZrQd on line 9 no
Output for 4.3.0 - 4.3.1
no Warning: exec() [http://www.php.net/function.exec]: Unable to fork [nslookup -type=MX gmail.com] in /in/AZrQd on line 6 Warning: Invalid argument supplied for foreach() in /in/AZrQd on line 9 no