LoginSignup
0
0

More than 5 years have passed since last update.

【PHP】サーバーのホスト名によって実行する処理を切り分ける

Last updated at Posted at 2018-09-07

$_SERVER['SERVER_ADDR'] が使えない

$_SERVER['SERVER_ADDR']を出力しようとするとエラーがでてしまう。
(サーバーの設定かな?わからん)

代わりにサーバーのホスト名で判定する

以下ソース

// 1号機以外は処理を実行しない
if (gethostname() === 'server_one') {
    // 1号機のみ実行する処理
}

参考

PHP: gethostname - Manual

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0