#30360 [Bgs]: empty string evaluates to string(0) php4.3.4 to string(1) in 5.0.2
| From: | daniel at spector dot ie | Date: | Fri, 08 Oct 2004 10:29:57 +0000 |
| Subject: | #30360 [Bgs]: empty string evaluates to string(0) php4.3.4 to string(1) in 5.0.2 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-67278@lists.php.net to get a copy of this message | ||
ID: 30360
User updated by: daniel at spector dot ie
Reported By: daniel at spector dot ie
Status: Bogus
Bug Type: Strings related
Operating System: Win2K
PHP Version: 5.0.2
New Comment:
Hm. Sorry for the hasty bug report, should have dug deeper, thanks for
the super prompt response. Reproduce code in fact works for me... as
you say.
'Bug' is in fact a 'feature' introduced in 4.3.4 (Bug #25777) as per
the 4.3.4 change log and rtrimming fields returned by MSSQL.
Codearound for me looks like.
Previous Comments:
------------------------------------------------------------------------
[2004-10-08 11:58:48] aidan@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
$ php -r '$suffix = ""; var_dump($suffix);'
string(0) ""
$ php -v
PHP 5.0.2-dev (cli) (built: Aug 26 2004 21:55:42)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.2-dev, Copyright (c) 1998-2004 Zend Technologies
Doesn't happen for me on linux.
<?php
$suffix = '';
var_dump($suffix);
?>
Doesn't happen for me on windows either.
In both cases empty returns true.
------------------------------------------------------------------------
[2004-10-08 11:58:07] derick@php.net
Works fine here:
derick@kossu:~$ php-5.0dev
<?php
$s = '';
var_dump($s);
?>
string(0) ""
------------------------------------------------------------------------
[2004-10-08 11:52:50] daniel at spector dot ie
Description:
------------
PHP4.3.4 to PHP5.0.2 empty('') string evaluates to
string(0) on 4.3.4(x?) and string(1) on php5.0.2. Can be
reproduced with code below.
Thanks alot in advance.
Reproduce code:
---------------
//an empty string
$suffix='';
var_dump($suffix);
$msg = (empty($suffix)) ? 'php4' : 'php5';
echo $msg;
/*
* on php4 var_dump returns string(0) msg returns php4
* on php5 var_dump returns string(1) msg returns php5
*/
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30360&edit=1