PHP字符串转换时如何保留long int?
以下 PHP 代码:
$someID = 124234454288758;
$queryStr => "SELECT a FROM b WHERE some_id = {$someID}";
转换为:
"SELECT a FROM b WHERE some_id = 1.2423445428876E+14"
我怎样才能得到结果字符串:
"SELECT a FROM b WHERE some_id = 124234454288758"
谢谢!
The following PHP code:
$someID = 124234454288758;
$queryStr => "SELECT a FROM b WHERE some_id = {$someID}";
is converted to:
"SELECT a FROM b WHERE some_id = 1.2423445428876E+14"
How can I get the result string as:
"SELECT a FROM b WHERE some_id = 124234454288758"
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
参考:big 的问题整数
Try this:
Reference: problems with big integers
使用 GMP (http://www.php.net/manual/en/book. gmp.php ) 或 BCMath ( http://www.php. net/manual/en/book.bc.php )在处理非常大的数字时。
Use GMP ( http://www.php.net/manual/en/book.gmp.php ) or BCMath ( http://www.php.net/manual/en/book.bc.php ) when dealing with very large numbers.
由于您没有对数字进行任何数学运算(因为它只是一个唯一的键),为什么不将其存储为字符串。
另外,值得一提的是,像这样的 SQL 查询创建通常会对 SQL 注入开放。您可能应该考虑使用 PDO,它是
prepare
功能。Since your not doing any math with the number (since it's just a unique key), why not just store it as a string.
Also, it's worth mentioning that SQL query creation like that is often open to SQL injection. You should probably consider using PDO and it's
prepare
functionality.