Jump to content

Archived

This topic is now archived and is closed to further replies.

Ninjakreborn

typecast

Recommended Posts

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.

Share this post


Link to post
Share on other sites
[!--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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.