|
Posted by Vince Morgan on 04/20/07 17:43
"Steve" <no.one@example.com> wrote in message
news:Kc5Wh.1423$go5.521@newsfe12.lga...
>
> "Vince Morgan" <vinhar@REMOVEoptusnet.com.au> wrote in message
> news:4628caca$0$11788$afc38c87@news.optusnet.com.au...
> | I've just read that a var can be declared in php as follows:
> | string $var1;
> | integer $var2;
>
> well, the above is both casting and declaring...
>
> // cast
>
> (string) $var1;
>
> // declaring
>
> string $var1;
>
> | They aren't talking about casting.
> | I've never seen this before and trying it in vers 5.0.3.3 shows that it
> has
> | no idea about it either.
>
> there are more formal ways to cast in php. and you know me, i'm kind of
> religious about code. :)
>
> i use things like floatval(), intval(), bool()...and then settype().
>
> now for all of this casting and typing, php itself does precious little
even
> when it knows you've typed the data explicitly. really, it helps you in
> comparisons in statements/functions (i.e. if/then, function()). it also
> helps you get correct output to the browser...as in using sprint_f, or,
> ooooh, how about implicit casting using number_format (even though a
string
> is returned).
>
> anyway, hth.
>
>
Thanks Steve. I found if I use brackets it worked. I'm glad you cleared up
it's limited usefullness. Was beginning to feel like to C ish ;)
Vince
Navigation:
[Reply to this message]
|