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

What are the differences between intval and floor functions in php

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

Share

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

This article mainly talks about "what are the differences between intval and floor functions in php". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the differences between intval and floor functions in php?"

Differences: 1, the intval () function is directly rounded off the decimal part, while the floor () function when the parameter is greater than 1, the decimal part is rounded, when the parameter is less than 1, the decimal part is removed and 1 is added on the basis of the integer. 2. The intval () function can be converted to binary, but not the floor function.

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

In php, both the intval and floor functions can be used for decimal rounding, so what's the difference between them? Let's take a look.

Floor () function

The floor () function rounds down to the nearest integer.

Syntax: floor (x)

Returns the next integer not greater than x, rounding off the fractional portion of x. The type returned by floor () is still float, because the range of float values is usually larger than integer.

Output:

0055-6-6

Intval () function

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

Syntax:

Int intval (mixed var, int [base])

Return value: integer

Function type: PHP system function

Output:

forty-four

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.

At this point, I believe you have a deeper understanding of "what is the difference between intval and floor functions in php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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