You are here: Re: Truly bizzare 'echo' problem « PHP Programming Language « IT news, forums, messages
Re: Truly bizzare 'echo' problem

Posted by Tim Roberts on 11/18/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.

 

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

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