1
0

More than 3 years have passed since last update.

phpのスーパーグローバル変数の定義variables_orderについて

Posted at

variables_orderとは

php.iniには以下の定義があります。

variables_order = "EGPCS"

それぞれスーパーグローバル変数の作成をする定義をします。
それぞれ頭文字で以下を表わします。

E:Environment (環境変数)
G:Get
P:Post
C:Cookie (クッキー)
S:Server

Eは指定しないほうがいいのか?

phpのバージョンによってはデフォルト値が変わってくるようです。
7.3に上げたら"GPCS"となりました。

; This directive determines which super global arrays are registered when PHP
; starts up. G,P,C,E & S are abbreviations for the following respective super
; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty
; paid for the registration of these arrays and because ENV is not as commonly
; used as the others, ENV is not recommended on productions servers. You
; can still get access to the environment variables through getenv() should you
; need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
; http://php.net/variables-order

コメントにもあるとおりEは推奨しないとのことです。
パフォーマンスにも影響するようです。

CGI および FastCGI SAPI の両方で、 $_SERVER にも環境変数の値が格納されます。 つまり、S を指定すると、 ES と指定したのと同じ意味になります。 これは、E が他のどこかで指定されていたとしても同じです。

ちなみにこの一文のようにphp-fpmを使用しているとENVとSERVERには同様の値が入っていました。
なのでEは指定する必要がなおさらなさそうですね。

1
0
1

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
1
0