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.