Ninjakreborn Posted April 18, 2006 Share Posted April 18, 2006 is it best to typecast each and every variable you use, like to make it a habit of always and every single time you create a variable you typecast it to what you want it to be set too. Quote Link to comment https://forums.phpfreaks.com/topic/7668-typecast/ Share on other sites More sharing options...
poirot Posted April 18, 2006 Share Posted April 18, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--](int), (integer) - cast to integer(bool), (boolean) - cast to boolean(float), (double), (real) - cast to float(string) - cast to string(array) - cast to array(object) - cast to object[/quote]Like:[code]<?php$foo = 10; // $foo is an integer$bar = (boolean) $foo; // $bar is a boolean?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7668-typecast/#findComment-27971 Share on other sites More sharing options...
Ninjakreborn Posted April 18, 2006 Author Share Posted April 18, 2006 one more quick question then, that helps alot, but should I ALWAYS type cast, for any specific purpose, or just for specific reasons, if so what reasons. Quote Link to comment https://forums.phpfreaks.com/topic/7668-typecast/#findComment-27975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.