PHP code to check if local server

WBOY
Release: 2016-07-25 08:58:32
Original
1145 people have browsed it
This article introduces a piece of PHP code used to detect whether it is a local server. It is very simple and can be used as a reference for beginners.

Check whether it is a local server and take next steps. code show as below:

<?php
/**
* 检测服务器属性
* edit bbs.it-home.org
*/

function is_localhost() {
 $localhost_ids = array('localhost', '127.0.0.1');
 if(in_array($_SERVER['HTTP_HOST'],$localhost_ids)){
    // not valid
    return 1;
 }
 }
?>
Copy after login

Code description: Obtain the server information through $_SERVER['HTTP_HOST'], and then match the setting value of the database to know whether it is a local server.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!