Nikhil Bhandari Nikhil Bhandari - 1 year ago 67
PHP Question

How to check if the php script is running on a local server?

Is it possible to check if the website (php) is running locally or on a hosted server?
I want to enable some logs if the website is running locally and I don't want these to appear on the site online..
I can set a variable

but I'll have to change that before uploading.. is there anyway to automate this task?

Local Server : WampServer 2.0 / Apache
WebServer: Apache

Answer Source

Check $_SERVER['REMOTE_ADDR']==''. This will only be true if running locally. Be aware that this means local to the server as well. So if you have any scripts running on the server which make requests to your PHP pages, they will satisfy this condition too.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download