intval和强制转换为int-`(int)X`之间有什么特别的区别吗? [英] Is there any particular difference between intval and casting to int - `(int) X`?

查看:105
本文介绍了intval和强制转换为int-`(int)X`之间有什么特别的区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

intval和(int)之间有什么特别的区别吗?

Is there any particular difference between intval and (int)?

示例:

$product_id = intval($_GET['pid']);
$product_id = (int) $_GET['pid'];

以上两行代码之间有什么特别的区别吗?

Is there any particular difference between above two lines of code?

推荐答案

intval()可以是通过了要转换的基准. (int)不能.

int intval( mixed $var  [, int $base = 10  ] )

这篇关于intval和强制转换为int-`(int)X`之间有什么特别的区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆