php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #25865 ini_get returns 0 not "" for boolean?
Submitted: 2003-10-14 11:44 UTC Modified: 2004-08-07 18:46 UTC
From: php dot net at b-a-l-u dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php dot net at b-a-l-u dot de
New email:
PHP Version: OS:

 

 [2003-10-14 11:44 UTC] php dot net at b-a-l-u dot de
Description:
------------
http://www.php.net/manual/en/function.ini-get.php 
tells me that

"When querying boolean values:  A boolean ini value of off will be returned as an empty string while a boolean ini value of on will be returned as "1"."

But
echo '['.ini_get('register_globals').']';

displays '[0]' not '[]'?

At least this is the behaviour I have with php-4.1.2 on debian woody.

     Balu
PS: It'd be nice to add the hint of "beyer at <nospam>clickhand dot de" from the notes on that page regarding casting the value using (bool) to the main description.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-14 12:38 UTC] sniper@php.net
# php -r "var_dump(ini_get('register_globals'));"
string(0) ""


 [2004-07-07 18:48 UTC] a-konovalenko at yandex dot ru
This is not bogus! I can reproduce it when the option comes from the .htaccess file (set with php_flag). ini_get() returns "0" instead of "" for the options that are off.

I'm using PHP 4.3.4 under Apache 1.3.31.

(Even if this is fixed in the latest version of PHP, the documentation should be updated for the older ones.)

P.S. Will my comment reopen this bug automatically or should I do something special?
 [2004-07-07 20:54 UTC] nlopess@php.net
re-open this.

reference: http://news.php.net/php.doc/969361748
 [2004-07-08 08:57 UTC] derick@php.net
Not a bug, nor a doc problem. It depends on where the option is set to return an empty string or 0.
 [2004-07-08 13:33 UTC] nlopess@php.net
It's a doc problem, at least!

Did you read my message on internals? (which nobody answered till now)
http://marc.theaimsgroup.com/?l=php-dev&m=108922680605154&w=2
 [2004-07-08 13:42 UTC] php dot net at b-a-l-u dot de
As I said in my opening message the documentation says 
 
"When querying boolean values: A boolean ini value of off 
will be returned as an empty string while a boolean ini 
value of on will be returned as "1". " 
 
So it IS a documentation problem if PHP<5 returns "" or 0 
depending on where it got set. 
 
I'd expect at least a warning like 
 
PHP versions before PHP5 return an empty string or 0 to 
specify a boolean value of false. The best way to test the 
return value is to cast it - e.g. 
$register_globals = (bool) ini_get('register_gobals'); 
 
Balu
 [2004-08-07 18:46 UTC] vrana@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: Thu Nov 20 17:00:01 2025 UTC