20

Here is the matter:

ini_set('display_errors', '1');
ini_set('safe_mode', '0');
ini_set('allow_url_fopen', '1');
ini_set('allow_url_include', '1');
print_r(ini_get_all());

And I get:

Array(
    [allow_url_fopen] => Array
        (
            [global_value] => 1
            [local_value] => 1
            [access] => 4
        )

    [allow_url_include] => Array
        (
            [global_value] => 
            [local_value] => 
            [access] => 4
        )

Why I cannot set that variable within the php ini_set function? The directive is specified as PHP_INI_ALL then it can be defined within the ini_set() function! http://php.net/manual/en/ini.list.php

6 Answers 6

17

display_errors

may be set at runtime (with ini_set()), but it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.

Use ini_set('display_errors','Off');

safe_mode

This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0. This directive belongs to PHP_INI_SYSTEM and Cannot be set via ini_set()

allow_url_include

Use ini_set('allow_url_include', 'On');

allow_url_fopen

This directive belongs to PHP_INI_SYSTEM and Cannot be set via ini_set()

2
  • What is the alternative of ini_set() in php5.3? If you dont have access to apache config files. The only option you have is to include in your code.
    – indago
    Dec 12, 2015 at 4:54
  • dude you are a legend, thanks very much, it has been bothering me all day.
    – Weilory
    Aug 19, 2020 at 4:55
8

These variables cannot be changed within a user script. The access value means:

PHP_INI_SYSTEM    4          Entry can be set in php.ini or httpd.conf  

You can try to set it in .htaccess:

php_value  allow_url_include 1
6
  • but here they say the opposite, it is an ini_set_all directive! php.net/manual/en/ini.list.php Sep 27, 2012 at 9:47
  • no, it is not ! they says that allow_url_fopen is PHP_INI_SYSTEM
    – artragis
    Sep 27, 2012 at 9:48
  • oh the first one you mean: but that variable is already on. It is set on true as you can see, isn't it...? Sep 27, 2012 at 9:49
  • ok: what abut the allow_url_include directive? that's my real point. Sep 27, 2012 at 9:53
  • can you try to set it in php.ini or .htaccess ?
    – wroniasty
    Sep 27, 2012 at 9:55
1

My answer might be off-topic but I almost always come back to this question via Google when my ini_set calls are not working. Sharing my case might help others to solve an issue with ini_set more quickly.

So, in my case display_errors is disabled but PHP still displays the errors in the browser although I enabled log_errors and set error_log to C:\Windows\Temp\PHP_error.log.

First impression is always that ini_set is not working BUT it might be a permission issue. If PHP cannot access the log file then it will simply send the errors to the browser.

Solution: make sure PHP has the permission to access and write the log file.

0

allow_url_fopen can't be modified by ini_set. It's because some ini statements has to be declared in an ini file only.

3
  • nope: here the available ini set directive, is not specified as an only php.ini directive! php.net/manual/en/ini.list.php Sep 27, 2012 at 9:44
  • what? i'm reading this by now: allow_url_include "0" PHP_INI_ALL PHP_INI_SYSTEM in PHP 5. Available since PHP 5.2.0. What am I missing in the php.net file? :( Sep 27, 2012 at 9:56
  • oh no i got itttttt, sorryyyyyyyyyyY!!! the second columns says the change in the php version!! sorry ;( Sep 27, 2012 at 9:56
0

Have you tried putting boolean values instead of 0 or 1?

ini_set('display_errors', true);
ini_set('safe_mode', false);
ini_set('allow_url_fopen', true);
ini_set('allow_url_include', true);
print_r(ini_get_all());

Or try this:

ini_set('allow_url_include', 'on');
0
-1

if you get this message in zabbix interface "ini_set(): Use of mbstring.internal_encoding is deprecated"

simply go to file vi /usr/local/share/zabbix/include/locales.inc.php and commet the line

#       ini_set('mbstring.internal_encoding', 'UTF-8');"

restart httpd & zabbix-server daemons , then try.. thats it.!

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.