|
Posted by Steve on 04/20/07 15:46
"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.
[Back to original message]
|