ID:               33443
 Updated by:       [EMAIL PROTECTED]
 Reported By:      nickj-phpbugs at nickj dot org
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: Irrelevant
 PHP Version:      Irrelevant
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

"The function can also return the literal string of INI value."


Previous Comments:
------------------------------------------------------------------------

[2007-06-17 23:23:29] phpbugs at thequod dot de

After 2 years the documentation has still not been fixed.
See http://php.net/ini_get

------------------------------------------------------------------------

[2005-07-08 12:02:42] [EMAIL PROTECTED]

Tony, what do you mean by "lot of changes in the engine and
extensions"? Since allow_url_fopen and others have on_modify handler set
to OnUpdateBool, everything should work, shouldn't it? It seems to me
that there is simply some bug causing that boolean value isn't converted
under some circumstances.

BTW ini_get("allow_url_fopen") returns "1" for me (Win XP, PHP 5.0.4),
but ini_set("display_errors", "On"); echo ini_get("display_errors");
displays "On".

------------------------------------------------------------------------

[2005-06-24 08:30:23] nickj-phpbugs at nickj dot org

I've just written a test-generator that creates .phpt tests for the
php.ini boolean directives, and I can safely say that the functioning of
ini_get() with most boolean values is really not good. 

So it's not just 'allow_fopen_url' that does not work as documented
with values like 'on', 'off', 'true', 'false', 'yes', and 'no'.

I made a test of roughly 67 boolean php.ini directives. It seems that
28 of these directives are hard-coded to be off (i.e. they ignore the
configuration directives), so they're impossible to test.

Of the remaining 39 boolean php.ini directives, I could not find a
single php.ini directive that passed every boolean test (0, 1, 'on',
'off', 'true', 'false', 'yes', 'no', 'none'). In fact, I could not even
find a boolean php.ini directive that passed the 'on' test, which is the
specific example used in the documentation. So there is not a single one
that works as documented.

The only thing which does seem to work is to use '0' and '1' for the
non-hard-coded boolean directives. For everything else, including 'on'
and 'off', ini_get() is simply not going to work as expected.

The test generator script is available for download at
http://home.swiftdsl.com.au/~npj/php-bugs/generate-ini-get-tests.phps
(Simply put it in an empty directory and run it, and it will generate
612 .phpt tests, which can then be run as normal for .phpt tests)

Based on the above, can I please make a suggestion? How about two
functions:
* ini_get() - retain the current function (which returns the literal
string), thus retaining backwards compatibility.
* ini_get_boolean() - returns a true boolean for boolean php.ini
directives. Should return either 'true' or 'false' (as distinct from
"0", "1" or ""), as then it never needs the (boolean) cast. Internally,
it could call ini_get(), and compare it to 0, 1, 'on', 'off', 'true',
'false', 'yes', 'no', 'none', and return the appropriate result.

------------------------------------------------------------------------

[2005-06-23 13:13:13] [EMAIL PROTECTED]

There no way to change it right now, as it will require a lot of
changes in the engine and extensions.
I'll change the docs to mention it.

------------------------------------------------------------------------

[2005-06-23 06:41:57] nickj-phpbugs at nickj dot org

The .phpt unit-tests are now available for download at:
http://home.swiftdsl.com.au/~npj/php-bugs/bug33443.zip (3KB file)

The results of running them on a PHP-5.1-dev build a few hours old was
as follows:
-----------------------------------------------------------------------
ludo:~/tmp/php-5.1-dev/php5-200506222230#
TEST_PHP_EXECUTABLE=sapi/cli/php sapi/cli/php run-tests.php
../bug33443/*.phpt

=====================================================================
CWD         : /root/tmp/php-5.1-dev/php5-200506222230
PHP         : sapi/cli/php 
PHP_SAPI    : cli
PHP_VERSION : 5.1.0-dev
ZEND_VERSION: 2.1.0-dev
PHP_OS      : Linux - Linux ludo 2.6.7-1-686 #1 Wed Jul 28 12:29:51
CEST 2004 i686
INI actual  : /root/tmp/php-5.1-dev/php5-200506222230/sapi/cli/php.ini
More .INIs  : 
Extra dirs  : 
=====================================================================
Running selected tests.
PASS Bug #33443 [0] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-0.phpt]
PASS Bug #33443 [1] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-1.phpt]
FAIL Bug #33443 [false] (ini_get("allow_url_fopen") should return
boolean string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-false.phpt]
FAIL Bug #33443 [no] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-no.phpt]
FAIL Bug #33443 [none] (ini_get("allow_url_fopen") should return
boolean string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-none.phpt]
FAIL Bug #33443 [off] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-off.phpt]
FAIL Bug #33443 [on-literal] (ini_get("allow_url_fopen") should return
boolean string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-on-literal.phpt]
PASS Bug #33443 [on] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-on.phpt]
PASS Bug #33443 [true] (ini_get("allow_url_fopen") should return
boolean string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-true.phpt]
PASS Bug #33443 [yes] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-yes.phpt]

=====================================================================
Number of tests :   10                10
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    5 ( 50.0%) ( 50.0%)
Tests passed    :    5 ( 50.0%) ( 50.0%)
---------------------------------------------------------------------
Time taken      :    0 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Bug #33443 [false] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-false.phpt]
Bug #33443 [no] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-no.phpt]
Bug #33443 [none] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-none.phpt]
Bug #33443 [off] (ini_get("allow_url_fopen") should return boolean
string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-off.phpt]
Bug #33443 [on-literal] (ini_get("allow_url_fopen") should return
boolean string, not the literal string)
[/root/tmp/php-5.1-dev/bug33443/bug33443-on-literal.phpt]
=====================================================================
ludo:~/tmp/php-5.1-dev/php5-200506222230# 
-----------------------------------------------------------------------

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/33443

-- 
Edit this bug report at http://bugs.php.net/?id=33443&edit=1

Reply via email to