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 php forcefully converts strings to int types

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

Share

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

This article introduces how php forcefully converts strings into int types. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Php strong string into int type methods: 1, the use of intval () function, you can get the integer value of the variable, syntax "intval (string variable)"; 2, using settype (), you can set the variable to the specified type, syntax "settype (string variable," integer ")".

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

Method 2: use the intval () function

The intval () function is used to get the integer value of a variable.

Description: the intval () function returns the integer value of the variable var by using the specified binary base conversion (the default is decimal). Intval () cannot be used for object, otherwise an E_NOTICE error will be generated and 1 will be returned.

Method 3: use the settype () function

"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)

Example:

Description:

The settype () function changes the type of the variable itself.

So much for sharing about how php forcibly converts strings to int types. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

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: 0

*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