[php-maint] Bug#346145: php4: Curly braces and brackets are treated equally

Sjoerd Hemminga sjoerd at hemminga-online.nl
Thu Jan 5 23:06:35 UTC 2006

Package: php4
Version: 4:4.4.0-4
Severity: normal

When using curly braces on an empty string to change a character at a
specified position, PHP will create an array.

The following code...

$bla = '';
$bla{0} = 'a';
var_dump ($bla);


array(1) {
  string(1) "a"

But if we change the first line to "$bla = ' ';", i.e. a string of one
space, we get the expected output:

string(1) "a"

The basic problem is that curly braces and square brackets are treated
exactly the same. From a semantic point of view, they aren't. PHP developers
seem to realize this, since they've deprecated the use of brackets for the
purpose of accessing arrays.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (700, 'testing'), (650, 'stable'), (600, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux
Locale: LANG=en_US.ISO-8859-15, LC_CTYPE=en_US.ISO-8859-15 (charmap=ISO-8859-15)

Versions of packages php4 depends on:
ii  libapache-mod-php4            4:4.4.0-4  server-side, HTML-embedded scripti
ii  php4-cgi                      4:4.4.0-4  server-side, HTML-embedded scripti
ii  php4-common                   4:4.4.0-4  Common files for packages built fr

php4 recommends no packages.

-- debconf information:
  php4/update_apache_php_ini: true

More information about the pkg-php-maint mailing list