|
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
Navigation:
[Reply to this message]
|