You are here: Re: I have seen much, but this... « PHP Programming Language « IT news, forums, messages
Re: I have seen much, but this...

Posted by Moot on 10/18/06 14:07

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";

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация