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.
Reply to discussion (solution)
Determine the value of $_server[' Http_host ']
Determine the value of $_server[' Http_host ']
I also want to use this, to determine whether it contains "localhost" or "127.0.0.1" and the like, but the total feeling seems to be not so cool.
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?
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?
Www.website.com can be a parameter after the Www.website.com/code=123&
You can print it out and see if it's clear.
echo $_server[' Http_host '];
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.
I use Strpos to match $_server[' http_host ' and target domain or URL to automatically determine the operating environment
You can determine the MAC address. Different computers, Macs are different.
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.
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.
Thank you, your answer solved the problem, not behind closed doors, very good.
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.
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.