What steps can be used to determine whether a program runs locally or on a server

Source: Internet
Author: User
What is the way to determine whether a program runs locally or on a server
Good morning, my friends, how can I determine whether the program is running locally or on a server?
For example
Local Localhost/website or 127.0.0.1/website
Server www. Website Com

I think the goal is to have a variable $ A
When on the server is $a=3, when local $a=2, just for this.
------to solve the idea----------------------
Determine the value of $_server[' Http_host ']
------to solve the idea----------------------
Not inclusive but equal to
Why "localhost" or "127.0.0.1" or something like that?
Is it OK to judge if it equals www.website.com?
------to solve the idea----------------------
You can print it out and see if it's clear.
echo $_server[' Http_host '];
------to solve the idea----------------------
I use Strpos to match $_server[' http_host ' and target domain or URL to automatically determine the operating environment
------to solve the idea----------------------
You can determine the MAC address. Different computers, Macs are different.
------to solve the idea----------------------
What is there to struggle with? A stake in your server is to support the two-level domain name, then the listing
In_array ($_server[' http_host '), array (domain Name list)
You can also use string comparisons

Anyway, you don't have to be behind closed doors.


Reference:
Quote: Reference:

You can print it out and see if it's clear.
echo $_server[' Http_host '];

You're saying, "Is it OK to judge if it equals www.website.com?" "But it could be with www and without www, and that's the problem.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.