Doc #53940 [Asn->Csd]: ini_get return values are (not) ambiguous
| From: | aharvey@php.net | Date: | Mon, 07 Feb 2011 07:23:52 +0000 |
| Subject: | Doc #53940 [Asn->Csd]: ini_get return values are (not) ambiguous | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5925@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53940&edit=1
ID: 53940
Updated by: aharvey@php.net
Reported by: colmacnamh at gmail dot com
Summary: ini_get return values are (not) ambiguous
-Status: Assigned
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: GNU linux but may be any
PHP Version: 5.3.5
Assigned To: aharvey
Block user comment: N
Private report: N
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.
Previous Comments:
------------------------------------------------------------------------
[2011-02-07 08:23:44] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=308083
Log: Fix doc bug #53940 (ini_get return values are (not) ambiguous).
------------------------------------------------------------------------
[2011-02-07 07:11:15] aharvey@php.net
The manual is wrong here: ini_get() returns false on error (most
commonly when the configuration directive doesn't exist), not an empty
string. This means that you can distinguish between ini_get() errors
and real configuration values.
I'll fix up the manual.
------------------------------------------------------------------------
[2011-02-06 17:57:15] colmacnamh at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.ini-get#Return
Values
---
Hello everyone!
First (since I am from Poland) I have to apologise for my english, it's
not very clean or gramatically correct but i'm sure you will understand
what i intend to say...
I am writing to you in order to make you noticed that the function
ini_get() returns value that cannot be properly identified using the
comparison operators (==,===,!==,etc) wheter this is an function error
or an empty string which implicates that the php.ini configuration
directive named 'disable_functions' (and not only this one) is empty
which means "not set".
---
From manual page: http://www.php.net/function.ini-get#Return
Values:
The function ini_get returns value of string type in two cases which
represents two different states of function:
- first it returns empty "string" value when the directive is empty
which also means "not set" (it's a neutral state - it's no error neither
other 'bad thing')
- secondly it returns empty "string" value when function encounters an
error during its runtime.
The bit operators (===, !==) cannot match wheter the returned value is
an error state or an "neutral" state (an empty string) because they're
both string type of data and they are both empty...
---
I wrote a short script to show you what problem i encounter. If there is
any solution which doesn't need rewriting the ini_get function code i
would be happy to hear it...below is the script i wrote :
Test script:
---------------
/*php.ini:
making the below directive empty which means not set
disable_functions =
*/
//storing the result into the variable for example
$iniget = ini_get('disable_functions');
if($iniget === '') {
die('disable_funtions failed');
/*
it fails at this point because the $iniget var may contain both the
function's error state (as an empty string) and the neutral state (as an
empty string) which means that this directive is not set but it's not an
error in anyway...
*/
}
Expected result:
----------------
the above script displays "disable_funtions failed" and prevent any
futher code from running.(die function) despite the fact that it's not
an error altough the php.ini's directive is
empty = not set...I hope you can see the problem here.
If this is
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53940&edit=1