ID:               26401
 User updated by:  bernhard at rainbow dot bksys dot at
 Reported By:      bernhard at rainbow dot bksys dot at
 Status:           Open
 Bug Type:         Arrays related
-Operating System: debian sid
+Operating System: debian sarge
 PHP Version:      4.3.2
 New Comment:

I'm using debian sarge (testing), not sid (unstable), at least I think
that's the correct code names now.


Previous Comments:
------------------------------------------------------------------------

[2003-11-25 06:41:09] bernhard at rainbow dot bksys dot at

Description:
------------
http://bksys.at/bernhard/phpbug.php?data=123

Only with the URL parameter data set to something,

$data[0] is the first character of the element last inserted
into the array $data[]

and $data[1++) yields the characters of $_REQUEST['data'][1++].

Though I have PHP 4.1.2, this also happened on PHP 4.3.2.



Reproduce code:
---------------
<html><body>
<?php
/*
why does this script print the first character of
$data['foo'] if called with the url parameter
data set to something, e.g. .../test.php?data=123
A bug?

*/

$data['dummy']='nothing';
$data['foo']='bar';
echo '[',$data[null],']';
echo '[',$data[''],']';
echo '[',$data[0],']';
echo '[',$data[1],']';
echo '[',$data[2],']';
echo '[',$data[3],']';
echo '[',$data[-1],']';
echo '[',$data[-2],']';

echo "<pre>";
echo htmlspecialchars(implode('',file($_SERVER['SCRIPT_FILENAME'])));
echo "</pre>";
phpinfo();
?>
</body></html>


Expected result:
----------------
[][][][][][][][]

<html><body>
<?php
/*
why does this script print the first character of
$data['foo'] if called with the url parameter
data set to something, e.g. .../test.php?data=123
A bug?

*/

$data['dummy']='nothing';
$data['foo']='bar';
echo '[',$data[null],']';
echo '[',$data[''],']';
echo '[',$data[0],']';
echo '[',$data[1],']';
echo '[',$data[2],']';
echo '[',$data[3],']';
echo '[',$data[-1],']';
echo '[',$data[-2],']';

echo "<pre>";
echo htmlspecialchars(implode('',file($_SERVER['SCRIPT_FILENAME'])));
echo "</pre>";
phpinfo();
?>
</body></html>

PHP Logo
PHP Version 4.1.2

Actual result:
--------------
[b][b][b][2][3][][][]

<html><body>
<?php
/*
why does this script print the first character of
$data['foo'] if called with the url parameter
data set to something, e.g. .../test.php?data=123
A bug?

*/

$data['dummy']='nothing';
$data['foo']='bar';
echo '[',$data[null],']';
echo '[',$data[''],']';
echo '[',$data[0],']';
echo '[',$data[1],']';
echo '[',$data[2],']';
echo '[',$data[3],']';
echo '[',$data[-1],']';
echo '[',$data[-2],']';

echo "<pre>";
echo htmlspecialchars(implode('',file($_SERVER['SCRIPT_FILENAME'])));
echo "</pre>";
phpinfo();
?>
</body></html>

PHP Logo
PHP Version 4.1.2


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=26401&edit=1

Reply via email to