为什么我在 php 串联中使用科学记数法
why I have scientific notation in php concatenation
我必须调用 API Restful 的端点,其中最后一个元素是资源 ID
http://midomain.com/resurces/:resourceID
resourceId 是 666769510661446146 但是当我将这个数字连接到 url
$url = "http://midomain.com/resources/" . $myId;
Php returns http://midomain.com/resources/6.6676951066145E+17
我尝试修复将数字转换为双倍并使用 sprintf 但它始终是相同的
谢谢!
您尝试过使用 number_format
吗?
$url = "http://midomain.com/resources/" . number_format($myId,0,"","");
这样你就可以避免科学表述。查看 official documentation 了解更多信息
您可以看到 example here
我必须调用 API Restful 的端点,其中最后一个元素是资源 ID
http://midomain.com/resurces/:resourceID
resourceId 是 666769510661446146 但是当我将这个数字连接到 url
$url = "http://midomain.com/resources/" . $myId;
Php returns http://midomain.com/resources/6.6676951066145E+17
我尝试修复将数字转换为双倍并使用 sprintf 但它始终是相同的
谢谢!
您尝试过使用 number_format
吗?
$url = "http://midomain.com/resources/" . number_format($myId,0,"","");
这样你就可以避免科学表述。查看 official documentation 了解更多信息
您可以看到 example here