php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53940 ini_get return values are (not) ambiguous
Submitted: 2011-02-06 17:57 UTC Modified: 2011-02-07 08:23 UTC
From: colmacnamh at gmail dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.5 OS: GNU linux but may be any
Private report: No CVE-ID: None
 [2011-02-06 17:57 UTC] 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 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-07 07:11 UTC] aharvey@php.net
-Summary: ... +Summary: ini_get return values are (not) ambiguous -Status: Open +Status: Assigned -Type: Feature/Change Request +Type: Documentation Problem -Package: *General Issues +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2011-02-07 07:11 UTC] 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-07 08:23 UTC] 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 08:23 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2011-02-07 08:23 UTC] aharvey@php.net
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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Aug 13 09:00:03 2025 UTC