Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vandanojan/d095229548a177da4c7726a0095d2e19 to your computer and use it in GitHub Desktop.
Save vandanojan/d095229548a177da4c7726a0095d2e19 to your computer and use it in GitHub Desktop.
This PHP script checks if the exec() function is enabled on the server. If so, it retrieves the server's IP address using the hostname -i command and returns it
<?php
if (function_exists('exec')) {
$ip_from_exec = exec('hostname -i');
echo "IP Address (via exec): $ip_from_exec";
} else {
echo "exec() function is not enabled on this server.";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment