The Plankmeister writes:
Is it better coding practice to do this:
$wibble = (bool)true;
$wobble = (int)108;
or just this:
This one. $wibble = true;
$wobble = 108;
The type is implicit in the values. You should only really use
casting where the input value is/could be of a different type to your
variable.
I think it's good practice to only store one type of value in a
variable. To keep track of this you can encode the type in the
variable name, using hungarian notation or something similar. For
instance:
s_wibble = "2"; // s_wibble always holds strings.
i_wobble = (int) s_wibble; // The need for a cast to int is obvious.
This has worked well for me in C, but you have to stick to it. It
isn't so useful in object oriented programming.
--
__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_)
www.alexfarran.com