PHP 类型转换函数intval

2015-01-24信息快讯网
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 
echo intval(42); // 42 
echo intval(4.2); // 4 
echo intval('42'); // 42 
echo intval('+42'); // 42 
echo intval('-42'); // -42 
echo intval(042); // 34 
echo intval('042'); // 42 
echo intval(1e10); // 1410065408 
echo intval('1e10'); // 1 
echo intval(0x1A); // 26 
echo intval(42000000); // 42000000 
echo intval(420000000000000000000); // 0 
echo intval('420000000000000000000'); // 2147483647 
echo intval(42, 8); // 42 
echo intval('42', 8); // 34 
?> 
php INI配置文件的解析实现分析
从php核心代码分析require和include的区别
深入理解PHP之require/include顺序 推荐
linux下删除7天前日志的代码(php+shell)
PHP中simplexml_load_string函数使用说明
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法
php数据入库前清理 注意php intval与mysql的int取值范围不同
php iconv() : Detected an illegal character in input string
php printf输出格式使用说明
php与paypal整合方法
网站用php实现paypal整合方法
php中var_export与var_dump的区别分析
php下关于Cannot use a scalar value as an array的解决办法
在PHP中实现Javascript的escape()函数代码
PHP中的integer类型使用分析
PHP print类函数使用总结
PHP,ASP.JAVA,JAVA代码格式化工具整理
php echo()和print()、require()和include()函数区别说明
php 图像函数大举例(非原创)
php MYSQL 数据备份类
phpmyadmin 访问被拒绝的真实原因
Windows PHP5和Apache的安装与配置
phpMyAdmin 安装配置方法和问题解决
IIS6+PHP5+MySQL5+Zend Optimizer+phpMyAdmin安装配置图文教程 2009年
Windows Apache2.2.11及Php5.2.9-1的安装与配置方法
php print EOF实现方法
将数组写入txt文件 var_export
在JavaScript中调用php程序
php动态生成JavaScript代码
php array_intersect()函数使用代码
Zend Studio for Eclipse的java.lang.NullPointerException错误的解决方法
PHP和Java 集成开发详解分析 强强联合第1/4页
php preg_match_all结合str_replace替换内容中所有img
php htmlentities和htmlspecialchars 的区别
php intval的测试代码发现问题
php sprintf()函数让你的sql操作更安全
php下intval()和(int)转换使用与区别
php扩展ZF――Validate扩展
©2014-2024 dbsqp.com