#31730 [Opn->Bgs]: behaviour of count() with strings
| From: | gschlossnagle@php.net | Date: | Thu, 27 Jan 2005 22:42:56 +0000 |
| Subject: | #31730 [Opn->Bgs]: behaviour of count() with strings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-72955@lists.php.net to get a copy of this message | ||
ID: 31730
Updated by: gschlossnagle@php.net
Reported By: tierra at ibaku dot net
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Linux 2.4.27
PHP Version: 5.0.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
strings are still strings. this would break all kinds
of bc.
Previous Comments:
------------------------------------------------------------------------
[2005-01-27 22:05:34] tierra at ibaku dot net
Description:
------------
This may not be a bug, but I would assume with the change in PHP5 (from
PHP4) where character access in strings is now done using array
operators that count('anystring') would return the length of the string
(being the number of array items in the string). I don't see any
official documentation on the reasoning for moving to array access
operators with strings in PHP5, but I've seen a number of reports that
it was for the movement of treating strings as arrays.
tierra@ibaku tierra $ php -v
PHP 5.0.3 (cli) (built: Dec 21 2004 20:37:03)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
tierra@ibaku tierra $ php count.php
count('string') returns: 1
tierra@ibaku tierra $ uname -a
Linux ibaku 2.4.27-linode36-3um #1 Fri Oct 29 00:59:10 EDT 2004 i686
UML User Mode Linux GNU/Linux
PHP Version => 5.0.3
System => Linux ibaku 2.4.27-linode36-3um #1 Fri Oct 29 00:59:10 EDT
2004 i686
Build Date => Dec 21 2004 20:26:48
Configure Command => './configure' '--prefix=/usr'
'--host=i686-pc-linux-gnu' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc'
'--localstatedir=/var
/lib' '--disable-cgi' '--enable-cli' '--enable-embed'
'--with-config-file-path=/etc/php/cli-php5' '--disable-bcmath'
'--without-bz2' '--disable-calendar' '--without-cpdflib'
'--disable-ctype' '--wi
th-curl' '--without-curlwrappers' '--disable-dbase'
'--disable-dio'
'--disable-exif' '--without-fam' '--without-fbsql'
'--without-fdftk'
'--disable-filepro' '--disable-ftp' '--with-gettext' '--with
out-gmp' '--without-hwapi' '--without-iconv' '--without-informix'
'--without-ingres' '--without-interbase' '--without-kerberos'
'--enable-mbstring' '--with-mcrypt' '--without-mcve'
'--disable-memor
y-limit' '--without-mhash' '--without-mime-magic'
'--without-ming'
'--without-mnogosearch' '--without-msql' '--without-mssql'
'--with-ncurses' '--without-oci8' '--without-oracle'
'--with-openssl'
'
--with-openssl-dir=/usr' '--without-ovrimos' '--disable-pcntl'
'--without-pfpro' '--without-pgsql' '--disable-posix'
'--with-pspell'
'--without-recode' '--disable-shmop' '--without-snmp' '--disable
-soap' '--disable-sockets' '--disable-spl' '--without-sybase'
'--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem'
'--disable-sysvshm' '--without-tidy' '--disable-tokenizer'
'--disable-wdd
x' '--with-xsl' '--with-xmlrpc' '--disable-yp'
'--with-zlib'
'--disable-debug' '--without-cdb' '--with-db4'
'--without-dbm'
'--without-flatfile' '--with-gdbm' '--without-inifile'
'--without-qdbm'
'
--with-jpeg-dir=/usr' '--with-freetype-dir=/usr' '--with-t1lib=/usr'
'--with-ttf=/usr' '--enable-gd-jis-conf' '--enable-gd-native-ttf'
'--with-png-dir=/usr' '--with-tiff-dir=/usr' '--without-xpm-di
r' '--with-gd' '--with-imap' '--with-imap-ssl'
'--with-mysql'
'--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--without-mm'
'--without-msession' '--enable-sqlite-utf8' '--enable-dba'
'--with-readl
ine' '--without-libedit'
Reproduce code:
---------------
<?php echo "count('string') returns: " . count('string') .
"\n"; ?>
Expected result:
----------------
count('string') returns: 6
Actual result:
--------------
count('string') returns: 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31730&edit=1