php type conversion

WBOY
Release: 2016-07-25 08:45:56
Original
1383 people have browsed it

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!