Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 整数需要转义吗_Php_Mysql_Codeigniter - Fatal编程技术网

Php 整数需要转义吗

Php 整数需要转义吗,php,mysql,codeigniter,Php,Mysql,Codeigniter,在使用intval()转换查询中的整数后,对其进行转义是否有意义 我使用的整数如下所示: $sql .= " LIMIT " . $this->db->escape(intval($offset)) . ", 10"; 否,将始终返回一个整数(0失败)。否。因为intval的结果是,除了数字之外,您不能接收任何内容 无需转义整数,只要验证了值实际上是一个整数——但如果$offset来自客户端输入,则应始终执行该验证无论如何都不应构建这样的查询字符串;使用参数化查询。正确地,(in

在使用
intval()
转换查询中的整数后,对其进行转义是否有意义

我使用的整数如下所示:

$sql .= " LIMIT " . $this->db->escape(intval($offset))  . ", 10";

否,将始终返回一个整数(
0
失败)。

否。因为intval的结果是,除了数字之外,您不能接收任何内容

无需转义整数,只要验证了值实际上是一个整数——但如果$offset来自客户端输入,则应始终执行该验证无论如何都不应构建这样的查询字符串;使用参数化查询。正确地,(int)和intval()始终返回sql安全值。