Reply to Re: string manipulation

Your name:

Reply:


Posted by Ivn Snchez Ortega on 09/04/07 00:00

ross.oneill@gmail.com wrote:

> [...] Any ideas what I am doing wrong?

You're forgetting that both . and - have the same precedence, and are
left-associative operators.

> $str = "this is a test" . (int)5-1;

That means that you're running this:

$str = ( "this is a test" . (int)5 ) -1;

Put in type juggling, and the result is that the string is eval'ed as (int
0, so you output 0 - 1 = -1.

But you do need to use parenthesis to overcome the precendence:


$str = "this is a test" . ( 5 - 1 );

or even

$str = "this is a test" . (int) ( 5 - 1 );


--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

La sabiduría me persigue, pero yo soy más rápido

[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

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