gpt4 book ai didi

php - 类型为 int(11) 的数据库值作为字符串返回

转载 作者:行者123 更新时间:2023-11-30 23:53:27 25 4
gpt4 key购买 nike

我有一个名为 customers_id 的 mysql 数据库表列,数据类型为 int(11)。

    echo gettype($customers['customers_id']);

结果我得到了字符串

    echo is_int($customers['customers_id']) ? 'yes' : 'no';

没有返回。

为什么整数值作为字符串返回?

更新:我使用 PDO 作为 access_layer。

最佳答案

它作为字符串从 PDO 返回。 is_int() 不会测试为真,但是如果您使用 is_numeric(),如果它是一串数字,它将测试为真。

$myint = '1';
echo is_int($myint) ? 'yes' : 'no'; //returns 'no'
echo is_numeric($myint) ? 'yes' : 'no'; //return 'yes'

关于php - 类型为 int(11) 的数据库值作为字符串返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19051723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com