Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert integer type to floating point type by php

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge of how php converts the whole type into a floating point. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

The way php converts an integer into a floating-point type: 1, use the floatval () function, the syntax is "floatval (integer value)"; 2, use the settype () function, and the syntax is "settype (integer value," float ").

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php converts an integer to a floating point type

Method 1: use the floatval () function

The floatval function is used to get the floating-point value of a variable.

Floatval cannot be used with arrays or objects.

Method 2:settype () function

The settype ($var,$type) function sets the variable $var to the specified data type $type.

Description:

The value of $type can be:

"boolean" (or "bool", starting with PHP 4.2.0)

"integer" (or "int", starting with PHP 4.2.0)

"float" (available only after PHP 4.2.0, "double" used in older versions is now disabled)

"string"

"array"

"object"

"null" (since PHP 4.2.0)

The settype () function changes the original variable.

These are all the contents of the article "how php converts integers to floating points". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 262

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report