Reply to Re: Truly bizzare 'echo' problem

Your name:

Reply:


Posted by Tim Roberts on 10/02/84 11:42

"fiziwig" <fiziwig@yahoo.com> wrote:

>Never mind. I figured it out. A php newbie brain fart. s/b echo
>'Records' . ($start+1); with parens.

That's correct, but do you understand why? The "." and "+" operators have
equal precedence, so the expression gets evaluated left-to-right.

echo 'Records ' . $start+1;

It computes "'Records ' . $start", which it does by converting $start to a
string, producing "Records 0". It then tries to add 1 to it, which it does
by converting the string to an integer. The string becomes 0, so the
result is 1, and that's what gets echoed.

One of the hazards of working with a loosely-typed language.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[Back to original 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

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