php ini_set ini_get 配置参数列表
name | default | changeable |
---|---|---|
com.allow_dcom | "0" | php教程_ini_system |
com.autoregister_typelib | "0" | php_ini_system |
com.autoregister_verbose | "0" | php_ini_system |
com.autoregister_casesensitive | "1" | php_ini_system |
com.typelib_file | "" | php_ini_system |
crack.default_dictionary | null | php_ini_system |
exif.encode_unicode | "iso-8859-15" | php_ini_all |
exif.decode_unicode_motorola | "ucs-2be" | php_ini_all |
exif.decode_unicode_intel | "ucs-2le" | php_ini_all |
exif.encode_jis | "" | php_ini_all |
exif.decode_jis_motorola | "jis" | php_ini_all |
exif.decode_jis_intel | "jis" | php_ini_all |
fbsql.allow_persistent | "1" | php_ini_system |
fbsql.generate_warnings | "0" | php_ini_system |
fbsql.autocommit | "1" | php_ini_system |
fbsql.max_persistent | "-1" | php_ini_system |
fbsql.max_links | "128" | php_ini_system |
fbsql.max_connections | "128" | php_ini_system |
fbsql.max_results | "128" | php_ini_system |
fbsql.batchsize | "1000" | php_ini_system |
fbsql.default_host | null | php_ini_system |
fbsql.default_user | "_system" | php_ini_system |
fbsql.default_password | "" | php_ini_system |
fbsql.default_database | "" | php_ini_system |
fbsql.default_database_password | "" | php_ini_system |
hwapi.allow_persistent | "0" | php_ini_system |
hyperwave.allow_persistent | "0" | php_ini_system |
hyperwave.default_port | "418" | php_ini_all |
iconv.input_encoding | iconv_input_encoding | php_ini_all |
iconv.output_encoding | iconv_output_encoding | php_ini_all |
iconv.internal_encoding | iconv_internal_encoding | php_ini_all |
ifx.allow_persistent | "1" | php_ini_system |
ifx.max_persistent | "-1" | php_ini_system |
ifx.max_links | "-1" | php_ini_system |
ifx.default_host | null | php_ini_system |
ifx.default_user | null | php_ini_system |
ifx.default_password | null | php_ini_system |
ifx.blobinfile | "1" | php_ini_all |
ifx.textasvarchar | "0" | php_ini_all |
ifx.byteasvarchar | "0" | php_ini_all |
ifx.charasvarchar | "0" | php_ini_all |
ifx.nullformat | "0" | php_ini_all |
ingres.allow_persistent | "1" | php_ini_system |
ingres.max_persistent | "-1" | php_ini_system |
ingres.max_links | "-1" | php_ini_system |
ingres.default_database | null | php_ini_all |
ingres.default_user | null | php_ini_all |
ingres.default_password | null | php_ini_all |
ibase.allow_persistent | "1" | php_ini_system |
ibase.max_persistent | "-1" | php_ini_system |
ibase.max_links | "-1" | php_ini_system |
ibase.default_user | null | php_ini_all |
ibase.default_password | null | php_ini_all |
ibase.timestampformat | "%m/%d/%y%h:%m:%s" | php_ini_all |
ibase.dateformat | "%m/%d/%y" | php_ini_all |
ibase.timeformat | "%h:%m:%s" | php_ini_all |
java.class.path | null | php_ini_all |
java.home | null | php_ini_all |
java.library.path | null | php_ini_all |
java.library | javalib | php_ini_all |
java.library | null | php_ini_all |
ldap.max_links | "-1" | php_ini_system |
mbstring.detect_order | null | php_ini_all |
mbstring.http_input | null | php_ini_all |
mbstring.http_output | null | php_ini_all |
mbstring.internal_encoding | null | php_ini_all |
mbstring.substitute_character | null | php_ini_all |
mbstring.func_overload | "0" | php_ini_system |
mcrypt.algorithms_dir | null | php_ini_all |
mcrypt.modes_dir | null | php_ini_all |
mime_magic.magicfile | "/usr/share/misc/magic.mime" | php_ini_system |
mssql.allow_persistent | "1" | php_ini_system |
mssql.max_persistent | "-1" | php_ini_system |
mssql.max_links | "-1" | php_ini_system |
mssql.max_procs | "25" | php_ini_all |
mssql.min_error_severity | "10" | php_ini_all |
mssql.min_message_severity | "10" | php_ini_all |
mssql.compatability_mode | "0" | php_ini_all |
mssql.connect_timeout | "5" | php_ini_all |
mssql.timeout | "60" | php_ini_all |
mssql.textsize | "-1" | php_ini_all |
mssql.textlimit | "-1" | php_ini_all |
mssql.batchsize | "0" | php_ini_all |
mssql.datetimeconvert | "1" | php_ini_all |
mssql.secure_connection | "0" | php_ini_system |
mysql教程.allow_persistent | "1" | php_ini_system |
mysql.max_persistent | "-1" | php_ini_system |
mysql.max_links | "-1" | php_ini_system |
mysql.default_host | null | php_ini_all |
mysql.default_user | null | php_ini_all |
mysql.default_password | null | php_ini_all |
mysql.default_port | null | php_ini_all |
mysql.default_socket | null | php_ini_all |
ncurses.value | "42" | php_ini_all |
ncurses.string | "foobar" | php_ini_all |
odbc.allow_persistent | "1" | php_ini_system |
odbc.max_persistent | "-1" | php_ini_system |
odbc.max_links | "-1" | php_ini_system |
odbc.default_db | null | php_ini_all |
odbc.default_user | null | php_ini_all |
odbc.default_pw | null | php_ini_all |
odbc.defaultlrl | "4096" | php_ini_all |
odbc.defaultbinmode | "1" | php_ini_all |
odbc.check_persistent | "1" | php_ini_system |
pfpro.defaulthost | "test.signio.com" | |
pfpro.defaulthost | "test-payflow.verisign.com" | |
pfpro.defaultport | "443" | php_ini_all |
pfpro.defaulttimeout | "30" | php_ini_all |
pfpro.proxyaddress | "" | php_ini_all |
pfpro.proxyport | "" | php_ini_all |
pfpro.proxylogon | "" | php_ini_all |
pfpro.proxypassword | "" | php_ini_all |
pgsql.allow_persistent | "1" | php_ini_system |
pgsql.max_persistent | "-1" | php_ini_system |
pgsql.max_links | "-1" | php_ini_system |
pgsql.auto_reset_persistent | "0" | php_ini_system |
pgsql.ignore_notice | "0" | php_ini_all |
pgsql.log_notice | "0" | php_ini_all |
session.save_path | "/tmp" | php_ini_all |
session.name | "phps教程essid" | php_ini_all |
session.save_handler | "files" | php_ini_all |
session.auto_start | "0" | php_ini_all |
session.gc_probability | "1" | php_ini_all |
session.gc_divisor | "100" | php_ini_all |
session.gc_maxlifetime | "1440" | php_ini_all |
session.serialize_handler | "php" | php_ini_all |
session.cookie_lifetime | "0" | php_ini_all |
session.cookie_path | "/" | php_ini_all |
session.cookie_domain | "" | php_ini_all |
session.cookie_secure | "" | php_ini_all |
session.use_cookies | "1" | php_ini_all |
session.use_only_cookies | "0" | php_ini_all |
session.referer_check | "" | php_ini_all |
session.entropy_file | "" | php_ini_all |
session.entropy_length | "0" | php_ini_all |
session.cache_limiter | "nocache" | php_ini_all |
session.cache_expire | "180" | php_ini_all |
session.use_trans_sid | "0" | php_ini_system php_ini_perdir |
session.encode_sources | "globals,track" | php_ini_all |
assert.active | "1" | php_ini_all |
assert.bail | "0" | php_ini_all |
assert.warning | "1" | php_ini_all |
assert.callback | null | php_ini_all |
assert.quiet_eval | "0" | php_ini_all |
safe_mode_protected_env_vars | safe_mode_protected_env_vars | php_ini_system |
safe_mode_allowed_env_vars | safe_mode_allowed_env_vars | php_ini_system |
url_rewriter.tags | "a=href,area=href, frame=src, form=fakeentry" |
php_ini_all |
sybct.allow_persistent | "1" | php_ini_system |
sybct.max_persistent | "-1" | php_ini_system |
sybct.max_links | "-1" | php_ini_system |
sybct.min_server_severity | "10" | php_ini_all |
sybct.min_client_severity | "10" | php_ini_all |
sybct.hostname | null | php_ini_all |
vpopmail.directory | "" | php_ini_all |
zlib.output_compression | "0" | php_ini_system php_ini_perdir |
zlib.output_compression_level | "-1" | php_ini_all |
define_syslog_variables | "0" | php_ini_all |
highlight.bg | hl_bg_color | php_ini_all |
highlight.comment | hl_comment_color | php_ini_all |
highlight.default | hl_default_color | php_ini_all |
highlight.html | hl_html_color | php_ini_all |
highlight.keyword | hl_keyword_color | php_ini_all |
highlight.string | hl_string_color | php_ini_all |
allow_call_time_pass_reference | "1" | php_ini_system php_ini_perdir |
asp教程_tags | "0" | php_ini_system php_ini_perdir |
display_errors | "1" | php_ini_all |
display_startup_errors | "0" | php_ini_all |
enable_dl | "1" | php_ini_system |
expose_php | "1" | php_ini_system |
html_errors | "1" | php_ini_all |
xmlrpc_errors | "0" | php_ini_system |
xmlrpc_error_number | "0" | php_ini_all |
ignore_user_abort | "0" | php_ini_all |
implicit_flush | "0" | php_ini_all |
log_errors | "0" | php_ini_all |
log_errors_max_len | "1024" | php_ini_all |
ignore_repeated_errors | "0" | php_ini_all |
ignore_repeated_source | "0" | php_ini_all |
magic_quotes_gpc | "1" | php_ini_perdir php_ini_system |
magic_quotes_runtime | "0" | php_ini_all |
magic_quotes_sybase | "0" | php_ini_all |
output_buffering | "0" | php_ini_perdir php_ini_system |
output_handler | null | php_ini_perdir php_ini_system |
register_argc_argv | "1" | php_ini_perdir php_ini_system |
register_globals | "0" | php_ini_perdir php_ini_system |
safe_mode | "1" | php_ini_system |
safe_mode | "0" | php_ini_system |
safe_mode_include_dir | null | php_ini_system |
safe_mode_gid | "0" | php_ini_system |
short_open_tag | default_short_open_tag | php_ini_system php_ini_perdir |
sql.safe_mode | "0" | php_ini_system |
track_errors | "0" | php_ini_all |
y2k_compliance | "0" | php_ini_all |
unserialize_callback_func | null | php_ini_all |
arg_separator.output | "&" | php_ini_all |
arg_separator.input | "&" | php_ini_system php_ini_perdir |
auto_append_file | null | php_ini_system php_ini_perdir |
auto_prepend_file | null | php_ini_system php_ini_perdir |
doc_root | null | php_ini_system |
default_charset | sapi_default_charset | php_ini_all |
default_mimetype | sapi_default_mimetype | php_ini_all |
error_log | null | php_ini_all |
extension_dir | php_extension_dir | php_ini_system |
gpc_order | "gpc" | php_ini_all |
include_path | php_include_path | php_ini_all |
max_execution_time | "30" | php_ini_all |
open_basedir | null | php_ini_system |
safe_mode_exec_dir | "1" | php_ini_system |
upload_max_filesize | "2m" | php_ini_system php_ini_perdir |
file_uploads | "1" | php_ini_system |
post_max_size | "8m" | php_ini_system php_ini_perdir |
upload_tmp_dir | null | php_ini_system |
user_dir | null | php_ini_system |
variables_order | null | php_ini_all |
error_append_string | null | php_ini_all |
error_prepend_string | null | php_ini_all |
smtp | "localhost" | php_ini_all |
smtp_port | 25 | php_ini_all |
browscap | null | php_ini_system |
error_reporting | null | php_ini_all |
memory_limit | "8m" | php_ini_all |
precision | "14" | php_ini_all |
sendmail_from | null | php_ini_all |
sendmail_path | default_sendmail_path | php_ini_system |
disable_classes | "" | php.ini only |
disable_functions | "" | php.ini only |
allow_url_fopen | "1" | php_ini_all |
always_populate_raw_post_data | "0" | php_ini_system php_ini_perdir |
xbithack | "0" | php_ini_all |
engine | "1" | php_ini_all |
last_modified | "0" | php_ini_all |
child_terminate | "0" | php_ini_all |
async_send | "0" | php_ini_all |
可操作范围见下表:
操作范围constant | value | meaning |
---|---|---|
php_ini_user | 1 | entry can be set in user scripts |
php_ini_perdir | 2 | entry can be set in php.ini, .htaccess or httpd.conf |
php_ini_system | 4 | entry can be set in php.ini or httpd.conf |
php_ini_all | 7 | entry can be set anywhere |
常量 | 值 | 含义 |
---|---|---|
php_ini_user | 1 | 该项目可以在用户脚本中设定 |
php_ini_perdir | 2 | 该项目可以在 php.ini ,.htaccess 或者 httpd.conf 中设定 |
php_ini_system | 4 | 该项目可以在 php.ini 或 httpd.conf 中设定 |
php_ini_all | 7 | 该项目可以在任何地方设定 |
ini_set ini_get 可操作配置参数列表
获取 magic_quotes_gpc 状态,来决定当表单提交时我们是否转义(addslashes)数据;
设定 max_execution_time 来延长 程序的执行时间;
设定 error_reporting 使自己的项目在开发与运营阶段切换;
设定 memory_limit 加大内存等等…
view sourceprint?1 ini_set (string varname, string newvalue ) : //设定环境配置的参数
2 ini_get (string varname) : //获取环境配置的参数
php ini_set函数是设置选项中的值,在执行函数后生效,脚本结束的时候,这个设置也失效。不是所有的选项都能被改函数设置的。具体那些值能够设置,可以查看手册中的列表。
就是能够设置php.ini中的选项值比如,display_error选项关闭 了,但是你要显示程序中的错误信息,方便你调试程序,那么就可以使用php ini_set函数:
view sourceprint?1 ini_set ( 'display_errors' , 'on' );
那么在你这个页面的程序都会显示错误信息了,而且你还可以使用error_reporting来设置显示的错误信息级别。
如果你需要增加脚本执行时间,那么可以设置:
view sourceprint?1 ini_set('max_execution_time', '180');
那么脚本执行时间就由默认的30秒变为180秒,当然,你也可以使用set_time_limit()来设置。
其实你把php ini_set函数和ini_get结合使的话,非常好。比如你想在配置文件里添加自己的包含文件路径,但是你有没有权限更改php.ini,那么你可以 结合两个函数:
view sourceprint?1 ini_set ( 'include_path' , ini_get ( 'include_path' ). ':/your_include_dir:' );
php配置函数ini_get()相信很多人都使过,就是获取配置文件中某一个选项的值,如果是true值就返回1,如果是false值就返回0,字符串就返回字符串。
比如手册中的例子:
view sourceprint?1
2 /* our php.ini contains the following settings: display_errors = on register_globals = off post_max_size = 8m */
3
4 echo 'display_errors = ' . ini_get ( 'display_errors' ) . " " ; //显示错误是否打开
5 echo 'register_globals = ' . ini_get ( 'register_globals' ) . " " ; //全局变量是否打开
6 echo 'post_max_size = ' . ini_get ( 'post_max_size' ) . " " ; //最多能提交的文件大小
7 echo 'post_max_size+1 = ' . ( ini_get ( 'post_max_size' )+1) . " " ;
8
9 ?>
输出:
display_errors = 1
register_globals = 0
post_max_size = 8m
post_max_size+1 = 9
php配置函数ini_get()主要是为了获取配置文件,可以方便你很多操作。 比如你想操作字符串过滤,但是又不清楚 magic_quotes_gpc有没有打开,所以你就可以这样写一个函数:
view sourceprint?1
2 /* 字符串过滤函数 */
3 function stringfilter( $str ) {
4 if ( ini_get ( 'magic_quotes_gpc)' ) { return $str ; } else { return addslashes ( $str ); }
5 }
6 ?>
当然,如果你无法知道你的全局变量是否打开,也可以定制这样的函数:
view sourceprint?1
2 /* 变量检测函数 */
3 function getgetvar( $var ) {
4 if ( ini_set ( 'register_gobals' )){ return $var ; } else { return $_get [ 'var' ]; }
5 }
6 ?>
当然,你可以用php配置函数ini_get()做很多用途