php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13270 Odd Math/String behaviour when 'echo'ing...
Submitted: 2001-09-12 14:55 UTC Modified: 2001-09-12 16:58 UTC
From: SeanECoates at yahoo dot ca Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.0.6 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
26 + 37 = ?
Subscribe to this entry?

 
 [2001-09-12 14:55 UTC] SeanECoates at yahoo dot ca
The following code produces strange output:
<?php
 echo "one".  1+2  ."two<br>\n";
 echo "one". (1+2) ."two<br>\n";
?>
(output:)
2two
one3two

maybe I'm overlooking something, but when excluding the parentheses, causes the first "one" to not display, and the addition to work incorrectly.
Please email me if you need more details. Obviously, the workaround is to put parentheses around the math.

Is this because, without parentheses, PHP is treating the statement like this:

echo "one1" + "2two"; // or something similar?

Using PHP4.0.6, Win32 pre-compiled. Other systems untested.

S

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-12 16:58 UTC] sniper@php.net
Just a matter of operator precedence:

http://www.php.net/manual/en/language.operators.precedence.php

Not a bug. (. is just another operator, as is + )

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC