|
|
 |
ini_set (PHP 4 , PHP 5) ini_set -- Establece el valor de una opción de
configuración Descripciónstring ini_set ( string nombre_var, string nuevo_valor)
Establece el valor de la opción de configuración
dada. Devuelve el valor antiguo en caso de éxito, FALSE
en caso de fallo. La opciÓn de configuración
mantendrá este nuevo valor durante la ejecución del
script, y será restablecido al final del script.
No todas las opciones disponibles pueden ser modificadas usando
ini_set(). A continuación se encuentra
una tabla con una lista de todas las opciones PHP (a la altura de
PHP 4.2.0), indicando cuáles pueden ser
modificadas/definidas y en qué nivel.
Tabla 1. Opciones de configuración | Nombre | Predeterminado | Modificable |
|---|
| allow_call_time_pass_reference | "1" | PHP_INI_PERDIR | | allow_url_fopen | "1" | PHP_INI_SYSTEM | | always_populate_raw_post_data | "0" | PHP_INI_PERDIR | | arg_separator.input | "&" | PHP_INI_PERDIR | | arg_separator.output | "&" | PHP_INI_ALL | | asp_tags | "0" | PHP_INI_PERDIR | | assert.active | "1" | PHP_INI_ALL | | assert.bail | "0" | PHP_INI_ALL | | assert.callback | NULL | PHP_INI_ALL | | assert.quiet_eval | "0" | PHP_INI_ALL | | assert.warning | "1" | PHP_INI_ALL | | auto_append_file | NULL | PHP_INI_PERDIR | | auto_detect_line_endings | "0" | PHP_INI_ALL | | auto_globals_jit | "1" | PHP_INI_PERDIR | | auto_prepend_file | NULL | PHP_INI_PERDIR | | bcmath.scale | "0" | PHP_INI_ALL | | browscap | NULL | PHP_INI_SYSTEM | | child_terminate | "0" | PHP_INI_ALL | | com.allow_dcom | "0" | PHP_INI_SYSTEM | | com.autoregister_casesensitive | "1" | PHP_INI_ALL | | com.autoregister_typelib | "0" | PHP_INI_ALL | | com.autoregister_verbose | "0" | PHP_INI_ALL | | com.code_page | "" | PHP_INI_ALL | | com.typelib_file | "" | PHP_INI_SYSTEM | | date.default_latitude | "31.7667" | PHP_INI_ALL | | date.default_longitude | "35.2333" | PHP_INI_ALL | | date.sunrise_zenith | "90.83" | PHP_INI_ALL | | date.sunset_zenith | "90.83" | PHP_INI_ALL | | dba.default_handler | "" | PHP_INI_ALL | | default_charset | "" | PHP_INI_ALL | | default_mimetype | "text/html" | PHP_INI_ALL | | default_socket_timeout | "60" | PHP_INI_ALL | | define_syslog_variables | "0" | PHP_INI_ALL | | disable_classes | "" | php.ini only | | disable_functions | "" | php.ini only | | display_errors | "1" | PHP_INI_ALL | | display_startup_errors | "0" | PHP_INI_ALL | | docref_ext | "" | PHP_INI_ALL | | docref_root | "" | PHP_INI_ALL | | doc_root | NULL | PHP_INI_SYSTEM | | enable_dl | "1" | PHP_INI_SYSTEM | | engine | "1" | PHP_INI_ALL | | error_append_string | NULL | PHP_INI_ALL | | error_log | NULL | PHP_INI_ALL | | error_prepend_string | NULL | PHP_INI_ALL | | exif.decode_jis_intel | "JIS" | PHP_INI_ALL | | exif.decode_jis_motorola | "JIS" | PHP_INI_ALL | | exif.decode_unicode_intel | "UCS-2LE" | PHP_INI_ALL | | exif.decode_unicode_motorola | "UCS-2BE" | PHP_INI_ALL | | exif.encode_jis | "" | PHP_INI_ALL | | exif.encode_unicode | "ISO-8859-15" | PHP_INI_ALL | | expose_php | "1" | php.ini only | | extension_dir | "@PREFIX@" | PHP_INI_SYSTEM | | fbsql.allow_persistent | "1" | PHP_INI_SYSTEM | | fbsql.autocommit | "1" | PHP_INI_SYSTEM | | fbsql.batchSize | "1000" | PHP_INI_SYSTEM | | fbsql.default_database | "" | PHP_INI_SYSTEM | | fbsql.default_database_password | "" | PHP_INI_SYSTEM | | fbsql.default_host | NULL | PHP_INI_SYSTEM | | fbsql.default_password | "" | PHP_INI_SYSTEM | | fbsql.default_user | "_SYSTEM" | PHP_INI_SYSTEM | | fbsql.generate_warnings | "0" | PHP_INI_SYSTEM | | fbsql.max_connections | "128" | PHP_INI_SYSTEM | | fbsql.max_links | "128" | PHP_INI_SYSTEM | | fbsql.max_persistent | "-1" | PHP_INI_SYSTEM | | fbsql.max_results | "128" | PHP_INI_SYSTEM | | file_uploads | "1" | PHP_INI_SYSTEM | | highlight.bg | "#FFFFFF" | PHP_INI_ALL | | highlight.comment | "#FF8000" | PHP_INI_ALL | | highlight.default | "#0000BB" | PHP_INI_ALL | | highlight.html | "#000000" | PHP_INI_ALL | | highlight.keyword | "#007700" | PHP_INI_ALL | | highlight.string | "#DD0000" | PHP_INI_ALL | | html_errors | "1" | PHP_INI_ALL | | ibase.allow_persistent | "1" | PHP_INI_SYSTEM | | ibase.dateformat | "%Y-%m-%d" | PHP_INI_ALL | | ibase.default_charset | NULL | PHP_INI_ALL | | ibase.default_db | NULL | PHP_INI_SYSTEM | | ibase.default_password | NULL | PHP_INI_ALL | | ibase.default_user | NULL | PHP_INI_ALL | | ibase.max_links | "-1" | PHP_INI_SYSTEM | | ibase.max_persistent | "-1" | PHP_INI_SYSTEM | | ibase.timeformat | "%H:%M:%S" | PHP_INI_ALL | | ibase.timestampformat | "%Y-%m-%d %H:%M:%S" | PHP_INI_ALL | | iconv.input_encoding | "ISO-8859-1" | PHP_INI_ALL | | iconv.internal_encoding | "ISO-8859-1" | PHP_INI_ALL | | iconv.output_encoding | "ISO-8859-1" | PHP_INI_ALL | | ifx.allow_persistent | "1" | PHP_INI_SYSTEM | | ifx.blobinfile | "1" | PHP_INI_ALL | | ifx.byteasvarchar | "0" | PHP_INI_ALL | | ifx.charasvarchar | "0" | PHP_INI_ALL | | ifx.default_host | NULL | PHP_INI_SYSTEM | | ifx.default_password | NULL | PHP_INI_SYSTEM | | ifx.default_user | NULL | PHP_INI_SYSTEM | | ifx.max_links | "-1" | PHP_INI_SYSTEM | | ifx.max_persistent | "-1" | PHP_INI_SYSTEM | | ifx.nullformat | "0" | PHP_INI_ALL | | ifx.textasvarchar | "0" | PHP_INI_ALL | | ignore_repeated_errors | "0" | PHP_INI_ALL | | ignore_repeated_source | "0" | PHP_INI_ALL | | ignore_user_abort | "0" | PHP_INI_ALL | | implicit_flush | "0" | PHP_INI_ALL | | include_path | ".;@PREFIX@\\pear" | PHP_INI_ALL | | ingres.allow_persistent | "1" | PHP_INI_SYSTEM | | ingres.default_database | NULL | PHP_INI_ALL | | ingres.default_password | NULL | PHP_INI_ALL | | ingres.default_user | NULL | PHP_INI_ALL | | ingres.max_links | "-1" | PHP_INI_SYSTEM | | ingres.max_persistent | "-1" | PHP_INI_SYSTEM | | ircg.control_user | "nobody" | PHP_INI_ALL | | ircg.keep_alive_interval | "60" | PHP_INI_ALL | | ircg.max_format_message_sets | "12" | PHP_INI_ALL | | ircg.shared_mem_size | "6000000" | PHP_INI_ALL | | ircg.work_dir | "/tmp/ircg" | PHP_INI_ALL | | last_modified | "0" | PHP_INI_ALL | | ldap.max_links | "-1" | PHP_INI_SYSTEM | | log_errors | "0" | PHP_INI_ALL | | log_errors_max_len | "1024" | PHP_INI_ALL | | magic_quotes_gpc | "1" | PHP_INI_PERDIR | | magic_quotes_runtime | "0" | PHP_INI_ALL | | magic_quotes_sybase | "0" | PHP_INI_ALL | | mail.force_extra_parameters | NULL | PHP_INI_PERDIR | | max_execution_time | "30" | PHP_INI_ALL | | max_input_time | "-1" | PHP_INI_PERDIR | | mbstring.detect_order | NULL | PHP_INI_ALL | | mbstring.encoding_translation | "0" | PHP_INI_PERDIR | | mbstring.func_overload | "0" | PHP_INI_PERDIR | | mbstring.http_input | "pass" | PHP_INI_ALL | | mbstring.http_output | "pass" | PHP_INI_ALL | | mbstring.internal_encoding | NULL | PHP_INI_ALL | | mbstring.language | "neutral" | PHP_INI_PERDIR | | mbstring.script_encoding | NULL | PHP_INI_ALL | | mbstring.substitute_character | NULL | PHP_INI_ALL | | mcrypt.algorithms_dir | NULL | PHP_INI_ALL | | mcrypt.modes_dir | NULL | PHP_INI_ALL | | memory_limit | "8M" | PHP_INI_ALL | | mime_magic.debug | "0" | PHP_INI_SYSTEM | | mime_magic.magicfile | PHP_PREFIX | PHP_INI_SYSTEM | | mssql.allow_persistent | "1" | PHP_INI_SYSTEM | | mssql.batchsize | "0" | PHP_INI_ALL | | mssql.compatability_mode | "0" | PHP_INI_ALL | | mssql.connect_timeout | "5" | PHP_INI_ALL | | mssql.datetimeconvert | "1" | PHP_INI_ALL | | mssql.max_links | "-1" | PHP_INI_SYSTEM | | mssql.max_persistent | "-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.secure_connection | "0" | PHP_INI_SYSTEM | | mssql.textlimit | "-1" | PHP_INI_ALL | | mssql.textsize | "-1" | PHP_INI_ALL | | mssql.timeout | "60" | PHP_INI_ALL | | mysql.allow_persistent | "1" | PHP_INI_SYSTEM | | mysql.connect_timeout | "60" | PHP_INI_ALL | | mysql.default_host | 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 | | mysql.default_user | NULL | PHP_INI_ALL | | mysql.max_links | "-1" | PHP_INI_SYSTEM | | mysql.max_persistent | "-1" | PHP_INI_SYSTEM | | mysql.trace_mode | "0" | PHP_INI_ALL | | mysqli.default_host | NULL | PHP_INI_ALL | | mysqli.default_port | "3306" | PHP_INI_ALL | | mysqli.default_pw | NULL | PHP_INI_ALL | | mysqli.default_socket | NULL | PHP_INI_ALL | | mysqli.default_user | NULL | PHP_INI_ALL | | mysqli.max_links | "-1" | PHP_INI_SYSTEM | | mysqli.reconnect | "0" | PHP_INI_SYSTEM | | nsapi.read_timeout | "60" | PHP_INI_ALL | | odbc.allow_persistent | "1" | PHP_INI_SYSTEM | | odbc.check_persistent | "1" | PHP_INI_SYSTEM | | odbc.defaultbinmode | "1" | PHP_INI_ALL | | odbc.defaultlrl | "4096" | PHP_INI_ALL | | odbc.default_db | NULL | PHP_INI_ALL | | odbc.default_pw | NULL | PHP_INI_ALL | | odbc.default_user | NULL | PHP_INI_ALL | | odbc.max_links | "-1" | PHP_INI_SYSTEM | | odbc.max_persistent | "-1" | PHP_INI_SYSTEM | | open_basedir | NULL | PHP_INI_SYSTEM | | output_buffering | "0" | PHP_INI_PERDIR | | output_handler | NULL | PHP_INI_PERDIR | | pfpro.defaulthost | "test-payflow.verisign.com" | PHP_INI_ALL | | pfpro.defaultport | "443" | PHP_INI_ALL | | pfpro.defaulttimeout | "30" | PHP_INI_ALL | | pfpro.proxyaddress | "" | PHP_INI_ALL | | pfpro.proxylogon | "" | PHP_INI_ALL | | pfpro.proxypassword | "" | PHP_INI_ALL | | pfpro.proxyport | "" | PHP_INI_ALL | | pgsql.allow_persistent | "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 | | pgsql.max_links | "-1" | PHP_INI_SYSTEM | | pgsql.max_persistent | "-1" | PHP_INI_SYSTEM | | post_max_size | "8M" | PHP_INI_PERDIR | | precision | "14" | PHP_INI_ALL | | register_argc_argv | "1" | PHP_INI_PERDIR | | register_globals | "0" | PHP_INI_PERDIR | | register_long_arrays | "1" | PHP_INI_PERDIR | | report_memleaks | "1" | PHP_INI_ALL | | report_zend_debug | "1" | PHP_INI_ALL | | safe_mode | "0" | PHP_INI_SYSTEM | | safe_mode_allowed_env_vars | "PHP_" | PHP_INI_SYSTEM | | safe_mode_exec_dir | "" | PHP_INI_SYSTEM | | safe_mode_gid | "0" | PHP_INI_SYSTEM | | safe_mode_include_dir | NULL | PHP_INI_SYSTEM | | safe_mode_protected_env_vars | "LD_LIBRARY_PATH" | PHP_INI_SYSTEM | | sendmail_from | NULL | PHP_INI_ALL | | sendmail_path | NULL | PHP_INI_SYSTEM | | serialize_precision | "100" | PHP_INI_ALL | | session.auto_start | "0" | PHP_INI_ALL | | session.bug_compat_42 | "1" | PHP_INI_ALL | | session.bug_compat_warn | "1" | PHP_INI_ALL | | session.cache_expire | "180" | PHP_INI_ALL | | session.cache_limiter | "nocache" | PHP_INI_ALL | | session.cookie_domain | "" | PHP_INI_ALL | | session.cookie_lifetime | "0" | PHP_INI_ALL | | session.cookie_path | "/" | PHP_INI_ALL | | session.cookie_secure | "" | PHP_INI_ALL | | session.entropy_file | "" | PHP_INI_ALL | | session.entropy_length | "0" | PHP_INI_ALL | | session.gc_divisor | "100" | PHP_INI_ALL | | session.gc_maxlifetime | "1440" | PHP_INI_ALL | | session.gc_probability | "1" | PHP_INI_ALL | | session.hash_bits_per_character | "4" | PHP_INI_ALL | | session.hash_function | "0" | PHP_INI_ALL | | session.name | "PHPSESSID" | PHP_INI_ALL | | session.referer_check | "" | PHP_INI_ALL | | session.save_handler | "files" | PHP_INI_ALL | | session.save_path | "" | PHP_INI_ALL | | session.serialize_handler | "php" | PHP_INI_ALL | | session.use_cookies | "1" | PHP_INI_ALL | | session.use_only_cookies | "0" | PHP_INI_ALL | | session.use_trans_sid | "0" | PHP_INI_ALL | | short_open_tag | "1" | PHP_INI_PERDIR | | SMTP | "localhost" | PHP_INI_ALL | | smtp_port | "25" | PHP_INI_ALL | | soap.wsdl_cache_dir | "/tmp" | PHP_INI_ALL | | soap.wsdl_cache_enabled | "1" | PHP_INI_ALL | | soap.wsdl_cache_ttl | "86400" | PHP_INI_ALL | | sql.safe_mode | "0" | PHP_INI_SYSTEM | | sqlite.assoc_case | "0" | PHP_INI_ALL | | sybct.allow_persistent | "1" | PHP_INI_SYSTEM | | sybct.deadlock_retry_count | "-1" | PHP_INI_ALL | | sybct.hostname | NULL | PHP_INI_ALL | | sybct.login_timeout | "-1" | PHP_INI_ALL | | sybct.max_links | "-1" | PHP_INI_SYSTEM | | sybct.max_persistent | "-1" | PHP_INI_SYSTEM | | sybct.min_client_severity | "10" | PHP_INI_ALL | | sybct.min_server_severity | "10" | PHP_INI_ALL | | tidy.clean_output | "0" | PHP_INI_PERDIR | | tidy.default_config | "" | PHP_INI_SYSTEM | | track_errors | "0" | PHP_INI_ALL | | unserialize_callback_func | NULL | PHP_INI_ALL | | upload_max_filesize | "2M" | PHP_INI_PERDIR | | upload_tmp_dir | NULL | PHP_INI_SYSTEM | | url_rewriter.tags | "a=href,area=href,frame=src,form=,fieldset=" | PHP_INI_ALL | | user_agent | NULL | PHP_INI_ALL | | user_dir | NULL | PHP_INI_SYSTEM | | variables_order | "EGPCS" | PHP_INI_ALL | | xbithack | "0" | PHP_INI_ALL | | xmlrpc_errors | "0" | PHP_INI_SYSTEM | | xmlrpc_error_number | "0" | PHP_INI_ALL | | y2k_compliance | "1" | PHP_INI_ALL | | zlib.output_compression | "0" | PHP_INI_ALL | | zlib.output_compression_level | "-1" | PHP_INI_ALL | | zlib.output_handler | "" | PHP_INI_ALL |
Tabla 2. Definición de las constantes PHP_INI_* | Constante | Valor | Significado |
|---|
| PHP_INI_USER | 1 | La entrada puede ser definida en scripts de
usuario | | PHP_INI_PERDIR | 2 |
La entrada puede definirse en php.ini, .htaccess o
httpd.conf
| | PHP_INI_SYSTEM | 4 |
La entrada puede definirse en php.ini o httpd.conf
| | PHP_INI_ALL | 7 | La entrada puede definirse en cualquier parte |
Vea también: get_cfg_var(),
ini_get(),
ini_get_all(), y
ini_restore()
toxalot
15-Sep-2004 08:53
brainiac5 dot php at aimail dot de
05-Sep-2004 04:54
To find the apache php settings try something like this.
> cd /etc/apache2
> grep -r -n -i safe_mode_exec_dir *.conf
or
> grep -r -n -i safe_mode.*On *.conf
If you find a gererated file, obviously you need to find the source template for it, to change what's needed there.
I just wasted a sunny Sunday on searching for where the heck safe_mode_exec_dir was changed.
And yes, Local Value in phpinfo does mean 'changed between the php.ini file and here', as you would think.
If you have an automated virtual host configuration, such as confixx, php ini values can be spread across very many files.
They can be changed in apache config files, that can have any name, but usually will end on .conf, besides in .htaccess files.
klw at gmx dot at
05-Sep-2004 03:49
To change settings from .htaccess files, it is also required that the directory permissions configured in Apache allow this.
The <Directory /foo/bar> entry in httpd.conf MUST contain "AllowOverride All" or at least "AllowOverride Options" to read PHP settings from the .htaccess file.
E.g. in Fedora Core 2, the default settings for /var/www/html/ are "AllowOverride None", so changing PHP settings via .htaccess for applications installed below /var/www/html/ will not work.
sean at php dot net
14-Aug-2004 03:54
jim at mookmedia dot co dot uk
11-Jun-2004 03:32
In reply to mike at dthought dot net:
Your code did not work for me.
I think the following would work better(notice the double $).
foreach ($_REQUEST as $request_key=>$request_value) {
if (isset($$request_key))
unset($$request_key);
}
this unsets all post and get globals.
Jim
vincent(at)tigroux(dot)net
30-Apr-2004 03:20
Where you want set ini in .htaccess or vhosts directives, if the value of directive is boolean , use php_flag, else if the value is a string use php_value.
Ex : php_value include_path /home/user/include
php_flag zlib.output_compression On
mike at dthought dot net
23-Feb-2004 07:34
Because, as mentioned previously, stuff such as register_globals is hit before your script executes and hence ini_set is not of much use here, I wrote this simple little bit of code to strip them back out (I sometimes have to work on a box that has register_globals enabled to allow backwards compatibility with some really old sites). Here it is:
foreach ($_GET as $get_key => $get_value) {
if (isset($get_key))
unset($get_key);
}
You can do the same for POSTed data if you wish, or even work it into a nice little automatic function.
davey at its-explosive dot net
18-Mar-2003 03:42
If you set something using php_admin_value in httpd.conf it is then not possible to be set the value at runtime, even if it's NOT PHP_INI_SYSTEM.
Just an interesting note for Server admins this might come in handy to disable setting of certain things... like allow_url_fopen.
- Davey
miroslav AT simunic DOT de
30-Sep-2002 05:26
If it´s not your server and therefore you want to hide the data in your session variables from other users, it´s very useful to set the session.save_handler in your scripts to shared memory with:
"ini_set('session.save_handler','mm')".
Remember: You have to set it in every script that uses the session variables BEFORE "session_start()" or php won´t find them.
Tr909 at com dot nospam dot bigfoot
12-Jun-2002 07:04
[[[Editors note: Yes, this is very true. Same with
register_globals, magic_quotes_gpc and others.
]]]
Many settings, although they do get set, have no influence in your script.... like upload_max_filesize will get set but uploaded files are already passed to your PHP script before the settings are changed.
Also other settings, set by ini_set(), may be to late because of this (post_max_size etc.).
beware, try settings thru php.ini or .htaccess.
johnzoet at netscape dot com
14-Mar-2002 03:13
[[[Editors note: Just because you're able to set something
doesn't mean it will work as expected. Depends on the
setting. For example. setting register_globals at
runtime will be of little use as its job has already
been completed by the time it reaches your script.
]]]
When a setting can not be changed in a user script, the return value of ini_set is "empty", not "false" as you may expect.
If you check in your script for return value is "false" the script will continue processing, although the setting has not been set.
The boolean return value is used for settings that can be changed in a script. Otherwise the empty value is returned.
To test for both error conditions use:
if (empty($blnResult) or (!$blnResult)) {
echo "setting cannot be set";
exit;
}
| |