Skip to content

Instantly share code, notes, and snippets.

@withgod
Created June 4, 2014 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save withgod/fb915cd209849113f754 to your computer and use it in GitHub Desktop.
Save withgod/fb915cd209849113f754 to your computer and use it in GitHub Desktop.
<?php
var_dump($_SERVER);
#環境によって微妙に違うから好きなの選ぶ為にvar_dump
#REQUEST_URI
#SCRIPT_NAME
#PHP_SELF
#SCRIPT_FILENAME
if (preg_match('/index.php/', $_SERVER['SCRIPT_NAME'])) {
include_once('/path/to/hoge.php');
}
#か
if (strpos($_SERVER['SCRIPT_NAME'], 'index.php') !== false ) { # 0番目が来たら誤検知するので厳密比較演算子使う
include_once('/path/to/hoge.php');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment