PHP.mk документација

ini_set

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.ini-set.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.ini-set.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
ini_set

Референца за `function.ini-set.php` со подобрена типографија и навигација.

function.ini-set.php

ini_set

(PHP 4, PHP 5, PHP 7, PHP 8)

ini_set(PHP 4, PHP 5, PHP 7, PHP 8)

= NULL

ini_set(string $option, string|int|float|bool|null $value): string|false

Поставува вредност на опција за конфигурација

Параметри

option

Поставува вредност на дадената опција за конфигурација. Опцијата за конфигурација ќе ја задржи оваа нова вредност за време на извршувањето на скриптата и ќе биде вратена на крајот од скриптата. ini_set()Не сите достапни опции можат да се променат со користење на appendix.

value

. Постои листа на сите достапни опции во

Вратени вредности

Новата вредност за опцијата. false при неуспех.

Дневник на промени

Верзија = NULL
8.1.0 value Враќа стара вредност при успех, nullсега прифаќа било кој скаларен тип (вклучувајќи string ). Претходно, само

Примери

вредности беа прифатени.

<?php
echo ini_get('display_errors');

if (!
ini_get('display_errors')) {
ini_set('display_errors', '1');
}

echo
ini_get('display_errors');
?>

Види Исто така

Белешки од корисници 13 белешки

nl-x
пред 11 години
I have experienced on some systems that ini_set() will fail and return a false, when trying to set a setting that was set inside php.ini inside a per-host setting. Beware of this.
- Враќа вредност на опција за конфигурација
пред 23 години
[[[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.
Tr909 at com dot nospam dot bigfoot
пред 8 години
When checking for the success of ini_set(), keep in mind that it will return the OLD value upon success - which may have been "0". Therefore you cannot just compare the return value - you have to check for "identity":

<?php

// This will NOT determine the success of ini_set(), instead
// it only tests if the old value had been equivalent to false
if ( !ini_set( 'display_errors', '1' ) ) 
    throw new \Exception( 'Unable to set display_errors.' );

// This is the CORRECT way to determine success
if ( ini_set( 'display_errors', '1' ) === false ) 
    throw new \Exception( 'Unable to set display_errors.' );    

?>

This explains reported situations where ini_set() "always" seems to fail!
ASchmidt at Anamera dot net
19 години пред
Be careful with setting an output_handler, as you can't use ini_set() to change it. *sigh*

In my php.ini I have this for my web pages (and I want it): 

  output_handler = ob_gzhandler

But this causes my command line scripts to not show output until the very end.

#!/usr/bin/php -q
<?php
ini_set('output_handler', 'mb_output_handler');
echo "\noutput_handler => " . ini_get('output_handler') . "\n";
?>

root@# ./myscript.php
output_handler => ob_gzhandler

Apparently (acording to Richard Lynch):

> TOO LATE!
> The ob_start() has already kicked in by this point.
> ob_flush() until there are no more buffers.
daevid at daevid dot com
пред 23 години
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:

<?php 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.
anonymous
пред 11 години
Note that this function only works with PHP_INI_ALL options!
miroslav AT simunic DOT de
пред 14 години
Careful - in some cases, when setting zlib.output_compression to "On" via ini_set, PHP won't send the Content-type header and browsers will garble the output. Set it to the desired buffer size instead, which sends the correct header:

<?php
ini_set("zlib.output_compression", 4096);
?>
Nathan
20 години пред
When your ISP does not allow you to add the default include directories - it might be useful to extend the 'include_path' variable:

<?php ini_set('include_path',ini_get('include_path').':../includes:');  ?>
RebootConcepts.com
19 години пред
set PHP_INI_PERDIR settings in a .htaccess file with 'php_flag' like this:

php_flag register_globals off
php_flag magic_quotes_gpc on
sean на php точка net
21 години пред
While this doesn't belong in the manual, it should be useful for people looking on this page for zend_optimizer.* ini options, which are commonly installed:

Information on the "zend_optimizer.optimization_level" and "zend_optimizer.enable_loader" options is available at:

http://www.zend.com/support/user_docs/ZendOptimizer/PDF/ZendOptimizer_UserGuide.pdf
johnzoet на netscape точка com
figroc at gmail dot com
[[[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:

<?php
if (empty($blnResult) or (!$blnResult)) {
   echo "setting cannot be set";
   exit;
}
?>
Er.ellison
пред 10 години
if u receive  an Error with generic like  :
Maximum execution time of 30 seconds exceeded 

if u set ini_set(max_execution_time, 300);
your problem will be solved 
pls note that the 300 , is 300 seconds , which means 5 minute  you can set another value !
Julien MOREAU познат како PixEye
пред 4 години
In order to change zend.assertions or assert.exception values, try with the ini_set() function but be aware that it may fail.

Example:
<?php
$ret = @ini_set('zend.assertions', '1');
if ($ret === false) echo 'ini_set() failed before line ', __LINE__, PHP_EOL;
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.