Home  >  Article  >  Backend Development  >  php type conversion

php type conversion

WBOY
WBOYOriginal
2016-07-25 08:45:561383browse

Using type conversion, you can convert the value of a variable to another type. This conversion is the same as the type conversion in C language. Just insert the temporary data type you want to convert in parentheses before the variable you want to type convert.
For example:

  1. $totalqty = 0;
  2. $totalamount = (float)$totalqty;
  3. ?>
Copy code

The second line of code means "take out the variable value stored in $totalqty, interpret it as a floating point type, and save it in $totalamount". The $totalamount variable will become a floating point type. The converted variable does not change its type, so $totalqty is still an integer type.

php


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn