phpの設定オプション指定方法(php.ini、 httpd.conf/.htaccess、php_ini等)
phpの設定オプション指定方法は、4種類
- php.ini
- httpd.conf
- .htaccess
- プログラム中に関数を呼び出す(ini_setなど)
それぞれの設定の仕方によって、設定オプションの有効にできる値と、できない値があります。
どれが有効化は、PHPのヘルプに一覧が載っています。
PHP: php.ini ディレクティブ - Manual
※Windowsの場合はレジストリでも設定できるそうです。まず使わないかと思われますが。
それぞれの書き方
php.ini
CODE:
-
magic_quotes_gpc = off
-
output_buffering = off
-
mbstring.language = Japanese
-
mbstring.encoding_translation = off
-
mbstring.http_input = pass
-
mbstring.http_output = pass
-
mbstring.internal_encoding = EUC-JP
-
mbstring.substitute_character = none
-
mbstring.detect_order = SJIS,EUC-JP,JIS,UTF-8,ASCII
httpd.conf と .htaccess(設定可能なオプションが違うけど、書式は同じ)
CODE:
-
php_flag magic_quotes_gpc off
-
php_flag output_buffering off
-
php_value mbstring.language Japanese
-
php_value mbstring.internal_encoding UTF-8
-
php_flag mbstring.encoding_translation off
-
php_value mbstring.http_input pass
-
php_value mbstring.http_output pass
-
php_value mbstring.substitute_character none
-
php_value mbstring.detect_order SJIS,EUC-JP,JIS,UTF-8,ASCII
以下のディレクティブでくくると、そのバージョンのモジュールのみ適用
CODE:
-
<IfModule mod_php5.c>
-
php_flag magic_quotes_gpc off
-
</IfModule>
-
<IfModule mod_php4.c>
-
php_flag magic_quotes_gpc on
-
</IfModule>
プログラム中
PHP:
PHP:
-
//それ用の関数を使う


