Answers for "php get local host"

PHP
1

php get hostname

<?php
echo gethostname(); // may output e.g,: sandie

// Or, an option that also works before PHP 5.3
echo php_uname('n'); // may output e.g,: sandie
?>
Posted by: Guest on April-14-2021
0

check if host is local in php

$whitelist = array(
    '127.0.0.1',
    '::1'
);

if(!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){
    // not valid
}
Posted by: Guest on March-25-2021

Browse Popular Code Answers by Language