You are here: Re: Butt ugly « PHP Programming Language « IT news, forums, messages
Re: Butt ugly

Posted by Rik on 05/27/06 15:43

Rik G. wrote:
> OK, thanks, that looks better but still: why does it eat the strings
> "2 + 2 = " and "test " in case 1 and 3?

See my other post.

> And here's for something even but uglier:
>
> echo "2 + 2 = " . 2+3; // This will print 5

1. String "2 + 2 = ".
2. String "2 + 2 = 2".
3. Gets cast to an integer because of +, which results in the first number:
integer "2".
4. Integer 2 + Integer 3 = 5

> echo "2 + 2 = " , 2+3; // This will print 2 + 2 = 5

1. String "2 + 2 = " get's echoed seperately.
2. Calculation 2+3 is performed.
3. Integer 5 is echoed seperately (the , operator is way, way down the
precedence list).

> echo "test " . 2+3; // This will print 3

1. String "test ".
2. String "test 2".
3. String gets cast to an integer, the first character is not a number or
'-' followed by a number, so gets cast to integer 0.
4. 0+3 = 3

Grtz,
--
Rik Wasmus

 

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

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