#32495 [Bgs->Opn]: Echo not producing correct result.
| From: | mike at cocoweb dot co dot uk | Date: | Wed, 30 Mar 2005 10:44:27 +0000 |
| Subject: | #32495 [Bgs->Opn]: Echo not producing correct result. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76046@lists.php.net to get a copy of this message | ||
ID: 32495
User updated by: mike at cocoweb dot co dot uk
Reported By: mike at cocoweb dot co dot uk
-Status: Bogus
+Status: Open
Bug Type: Strings related
Operating System: Windows XP
PHP Version: 5.0.3
New Comment:
Check out "Actual result: Expression 1". The double quotes are missing
around .func()
I should have made it more clear.
Previous Comments:
------------------------------------------------------------------------
[2005-03-30 07:45:50] sniper@php.net
I would be very worried if the output wasn't what you got.
(you're using single quotes..are you sure you've pasted the right code
here? :)
------------------------------------------------------------------------
[2005-03-30 04:49:20] mike at cocoweb dot co dot uk
Description:
------------
Unexpected output with echo statement.
Reproduce code:
---------------
<?php
// Expression 1
echo 'echo "<bob ".func()."></bob>";';
// Newline for "view source"
echo "\n";
// Expression 2
echo 'echo "<bob value=".func()."></bob>";';
// Newline for "view source"
echo "\n";
// Expression 3
echo 'echo "bob ".func()."></bob>";';
?>
Expected result:
----------------
echo "<bob ".func()."></bob>";
echo "<bob value=".func()."></bob>";
echo "bob ".func()."></bob>";
// Note extra newlines for ease of reading.
Actual result:
--------------
echo "<bob .func().></bob>";
echo "<bob value=".func()."></bob>";
echo "bob ".func()."></bob>";
Line 2 and 3 are expected. Line 1 is just plain weird!
Note that the '=' after 'value' makes the output work correctly.
Bizarre. I have looked in PHP books, the web and asked a couple of
experts all to no avail.
You can reduce the original code down to:
echo 'echo "<bob =".func()."></bob>";';
and it will give expected result! But remove the equals sign and the
bug will occur.
Also note removing the first < (i.e. before bob) will work too. (see
expression 3).
I'm possibly having a REALLY bad coding day and making a REALLY simple
error...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32495&edit=1