Reputation: 159
I am trying to find the hostname of the sql using wordpress. ie I wanted to print the 'localhost' from 'http://**localhost**/velocity/wordpress/?page_id=4'
I tried the function home_get_url(), but I got the entire path as shown above. When I was trying with gethostname() I got my PC name. '
Please help. I am a fresher to wordpress.
Upvotes: 0
Views: 1245
Reputation: 1062
Hope it will help you .
printf("MySQL host info: %s\n", mysql_get_host_info());
You can also try .
<?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
?>
For more info . http://www.php.net/manual/en/function.gethostname.php
Upvotes: 1
Reputation: 31749
You can use $_SERVER['HTTP_HOST']
For http://localhost/velocity/wordpress/?page_id=4
it will return http://localhost
Upvotes: 0