Jump to content

Type Casting

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
clookid

clookid

    Programmer

  • Members
  • PipPipPipPip
  • 125 posts
Type casting

Like Perl, variables are cast automatically into the right types (integer, floating point, string, etc.) though you can force them if you want. Just put the required type in front of the variable in brackets

  $mynum = 3.01;
  $intnum = (int) $mynum;

Check this out in the PHP manual if you want to know more about typecasting. In general it's not necessary since there are functions for dealing with (for example) number formatting.

This tutorial was written by another one of my friends, if you would like to use this tutorial please send me a PM

#2
xtraze

xtraze

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 910 posts
Better do this lol,
else problems can occur in some places, pre-caution is better.
And can you list some variable types here,

(int),....