PHP Velho Oeste 2024

実行時設定

php.ini の設定により動作が変化します。

PHP オプション/情報設定オプション
名前 デフォルト 変更可能 変更履歴
assert.active "1" INI_ALL PHP 8.3.0 以降は非推奨
assert.bail "0" INI_ALL PHP 8.3.0 以降は非推奨
assert.warning "1" INI_ALL PHP 8.3.0 以降は非推奨
assert.callback NULL INI_ALL PHP 8.3.0 以降は非推奨
assert.quiet_eval "0" INI_ALL PHP 8.0.0 で削除
assert.exception "1" INI_ALL PHP 8.0.0 より前のバージョンでは、デフォルト値は "0" でした。 PHP 8.3.0 以降は非推奨
enable_dl "1" INI_SYSTEM この非推奨の機能は、きっと 将来 削除 されるでしょう。
max_execution_time "30" INI_ALL  
max_input_time "-1" INI_PERDIR  
max_input_nesting_level "64" INI_PERDIR  
max_input_vars 1000 INI_PERDIR  
zend.enable_gc "1" INI_ALL  
INI_* モードの詳細および定義については どこで設定を行うのか を参照してください。

以下に設定ディレクティブに関する 簡単な説明を示します。

assert.active bool

assert() の評価を有効にします。 assert() の振る舞いを制御するには、 zend.assertions を代わりに使うべきです。

警告

この機能は PHP 8.3.0 で 非推奨になります。この機能に頼らないことを強く推奨します。

assert.bail bool

assertion が失敗した時にスクリプトの実行を終了します。

警告

この機能は PHP 8.3.0 で 非推奨になります。この機能に頼らないことを強く推奨します。

assert.warning bool

assertion が失敗する度に PHP 警告を発行します。

警告

この機能は PHP 8.3.0 で 非推奨になります。この機能に頼らないことを強く推奨します。

assert.callback string

assertion が失敗した時にコールされるユーザー関数

警告

この機能は PHP 8.3.0 で 非推奨になります。この機能に頼らないことを強く推奨します。

assert.quiet_eval bool
警告

この機能は、PHP 8.0.0 で 削除されました

assertion 式の評価時に error_reporting() の現在の 設定を使用します。有効な場合、評価時にエラーは表示されません。 (暗黙のうちに error_reporting(0) とします) 無効な場合、エラーは、error_reporting() の設定に 基づき設定されます。

assert.exception bool

アサーションに失敗した場合に AssertionError 例外を発行します。

警告

この機能は PHP 8.3.0 で 非推奨になります。この機能に頼らないことを強く推奨します。

enable_dl bool

このディレクティブを使うと、 PHP の拡張モジュールを dl() で動的にロードする機能を、オンまたはオフに変更することができます。

動的ロード機能をオフにするのは主としてセキュリティ上の理由によります。 動的ロード機能により、 open_basedir の拘束を全て 無視することが可能になります。 デフォルトでは、動的ロードが可能です。

max_execution_time int

スクリプトがパーサにより強制終了されるまでに許容される最大の 時間を秒単位で指定します。この命令は、いい加減に書かれた スクリプトがサーバーの負荷を上げることを防止するのに役立ちます。 デフォルトでは、30 に設定されています。 PHP を コマンドライン から実行する場合のデフォルト設定は 0 です。

Windows 以外のシステムでは、 最大実行時間は、システムコール、ストリーム操作等の 影響を受けません。より詳細な情報については、 set_time_limit() 関数の説明を参照ください。

Web サーバー側でもタイムアウトの設定項目を持ち、 その設定で PHP の実行が中断されることもあります。 Apache には Timeout ディレクティブ、IIS には CGI タイムアウト関数があり、どちらもデフォルトで 300 秒に設定されています。 これらの意味については、Web サーバーのドキュメントを参照ください。

max_input_time int

スクリプトが POST、GET などの入力を パースする最大の時間を、秒単位で指定します。 これは、サーバー側で PHP が起動してからスクリプトの実行を開始するまでの時間です。 デフォルトの設定は -1 です。 これは max_execution_time が代わりに使われることを意味しています。 無制限にするには、0 を設定してください。

max_input_nesting_level int

外部からの入力変数 ($_GET$_POST など) のネストの深さの最大値を設定します。

max_input_vars int

入力変数 を最大で何個まで受け付けるかを指定します (この制限は、スーパーグローバル $_GET、$_POST そして $_COOKIE にそれぞれ個別に適用されます)。 このディレクティブを使うと、ハッシュの衝突を悪用したサービス不能攻撃を受ける可能性を軽減できます。 このディレクティブで設定した数を超える入力変数があった場合は E_WARNING が発生し、 それ以降の入力変数はリクエストから削除されます。

zend.enable_gc bool

循環参照コレクタを有効あるいは無効にします。

add a note add a note

User Contributed Notes 4 notes

up
21
rubo77
10 years ago
I think it is important to mention that some distributions apply bugfixes for older versions so "Available since PHP 5.3.9" is not reliable, for example:
debian squeeze implemented the directive max_input_vars in PHP 5.3.3-7+squeeze7 (see http://ftp-master.metadata.debian.org/changelogs/main/p/php5/php5_5.3.3-7+squeeze17_changelog )
up
1
csongor at halmai dot hu
4 years ago
The max_input_vars setting is defined as "How many input variables may be accepted" but this is not completely correct. There is a +1 factor.

For example, if the value is 2 then the $_POST array can have up to 3 elements, if it is 1000 then it can have 1001 elements, and so on.

I want to stop the execution of the php code when there is a chance that some data was not received. Therefore, instead of relying on the standard E_WARNING, I do this in my code.

<?php
$max_input_vars
= ini_get('max_input_vars');
if (
count($_POST) === $max_input_vars + 1) {   // note the +1 here
   
throw new Exception();
}
?>

If the size of the $_POST array reaches the maximum then there is the chance that there was more data so it is better to stay on the safe side and increase the config value.
up
-4
horst at pepperzak.com
12 years ago
Caution: Although magic_quotes_gpc is flagged as dreprecated the default value is still "ON". So you will explicitly have to put

magic_quotes_gpc = Off

into your php.ini. Commeting out the magic_quotes_gpc-line will not turn magic_quotes_gpc off.
up
-86
Anonymous
10 years ago
The max_input_vars limit can be overcome by reading the input in raw, i.e.:
<?php
  $sRawInputData
= fopen( 'php://input' );
?>
To Top