From:             mike at cocoweb dot co dot uk
Operating system: Windows XP
PHP version:      5.0.3
PHP Bug Type:     Strings related
Bug description:  Echo not producing correct result.

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 bug report at http://bugs.php.net/?id=32495&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32495&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32495&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32495&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32495&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32495&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32495&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32495&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32495&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32495&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32495&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32495&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32495&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32495&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32495&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32495&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32495&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32495&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32495&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32495&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32495&r=mysqlcfg

Reply via email to