PHP 类型转换函数intval

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了PHP 类型转换函数intval脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

PHP代码

$id = intval($_GET['id']);

intval

(PHP 4,PHP 5)
intval — Get the integer value of a VARiable

Description


int intval ( mixed $var [,int $base= 10 ] )
Returns the integer value of var,using the sPEcified base for the conversion (the default is base 10).
Parameters

var

The scalar value being converted to an integer

base

The base for the conversion (default is base 10)

Return Values

The integer value of var on success,or 0 on failure. Empty arrays and objects return 0,non-empty arrays and objects return 1.
The maximum value depends on the system. 32 bIT systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system,intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807.
Strings will most likely return 0 although this depends on the leftmost characters of the string. The common rules of integer casting apply.

Examples

代码如下:

脚本宝典总结

以上是脚本宝典为你收集整理的PHP 类型转换函数intval全部内容,希望文章能够帮你解决PHP 类型转换函数intval所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。