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

前端 未结 6 2071
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 00:44

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 ap

6条回答
  •  不思量自难忘°
    2021-02-15 01:29

    Check $_SERVER['REMOTE_ADDR']=='127.0.0.1'. 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.

提交回复
热议问题