473,378 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

I have seen much, but this...

I have 2 pieces of code, where one works, another does not, even they
should be the same

echo " <td$s $s2</td><td>$s-";
echo $s+$s2." </td></tr>\r\n";

which can be truncated to

echo " <td$s $s2</td><td>$s-".$s+$s2." </td></tr>\r\n";

All in one line, but then the first part in the "" will not be printed,
result: 45</td></tr- a funny table.
There should be no difference, but there is.

$s and $s2 are integer, the entire table is for debugging. The error is
known and I can work around this.

But i cannot explain it.

BR
Sonnich

Oct 18 '06 #1
2 1057
jodleren wrote:
I have 2 pieces of code, where one works, another does not, even they
should be the same

echo " <td$s $s2</td><td>$s-";
echo $s+$s2." </td></tr>\r\n";

which can be truncated to

echo " <td$s $s2</td><td>$s-".$s+$s2." </td></tr>\r\n";

All in one line, but then the first part in the "" will not be printed,
result: 45</td></tr- a funny table.
There should be no difference, but there is.

$s and $s2 are integer, the entire table is for debugging. The error is
known and I can work around this.

But i cannot explain it.

BR
Sonnich

When doing math within a string concatenation, you need to use
parethesis.
So your second example becomes:
echo " <td$s $s2</td><td>$s-". ($s+$s2) ." </td></tr>\r\n";

Oct 18 '06 #2

jodleren wrote:
echo " <td$s $s2</td><td>$s-";
echo $s+$s2." </td></tr>\r\n";

which can be truncated to

echo " <td$s $s2</td><td>$s-".$s+$s2." </td></tr>\r\n";
Precedence. Try:

echo " <td$s $s2</td><td>$s-".($s+$s2)." </td></tr>\r\n";
There should be no difference, but there is.
Of course there *is* quite a difference. You just failed to
notice it.

--
Pavel Lepin

Oct 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: aa | last post by:
Is a PHP variable supposed to be seen in a .js file included into a .php file? I have a client side javascript code stored in a .js file which is included into a PHP file using <script...
2
by: Robert Oschler | last post by:
One of the recurring bugs I find in my program, is a bug due to a misspelling of a variable name. Is there a code checker out there that can help find these critters? If so, URL's please. ...
0
by: Richard Hanson | last post by:
Seen on news:gmane.comp.python.devel in message-IDs <16668.57809.362313.36355@montanaro.dyndns.org> and <16669.7113.531528.462699@montanaro.dyndns.org> : > def p_statement_expr: > ...
9
by: syd | last post by:
I don't even know where to begin. This is just bizarre. I just picked up the Gnuplot.py module (a light interface to gnuplot commands) and was messing around with it today. I've got a tiny...
1
by: Miki Tebeka | last post by:
Hello All, Is there a way to know in a POP session of a message was seen (old) or not (new)? Thanks. -- ------------------------------------------------------------------------ Miki Tebeka...
6
by: Mr. x | last post by:
Hello, The following show in netscape with a line delemiter between each row. How can I avoid this behaviour in Netscape ? <asp:Table runat="server" CellPadding="0" GridLines="horizontal"...
0
by: Mr. x | last post by:
Hello, I am sending this emal again, because it was a week ago, and I want to clarify some new things. I have problem on .NET, which are seen differently on IE and Netscape. Look at sit of...
8
by: Wayne Gillespie | last post by:
I have an application in service (A97) which is a booking system for a modelling agency. When they add / edit a job I display a subform which lists all models, filtered according to criteria set by...
0
by: Pritesh | last post by:
Hi, We r using oracle application server 9i and form/report 6i. We called graph from report which r opening in PDF format. When we run report from report builder, graph patterns r seen but from...
27
by: blangela | last post by:
What does the second const in the member function prototype below dprotect? I believe the first const prevents the reference returned from being modified and the third prevents the member function...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.