Modulo是不正确的PHP

时间:2016-04-03 13:37:29

标签: php

所以,我正在执行下面的代码,$rolled_number返回-7而不是9.我已经在http://www.phptester.net/检查了我的代码,结果是9.我相信这是由于模数。如果有人知道为什么我的代码在我的本地Web服务器上不起作用但在其他网站上有效,那么请告诉我。我的Web服务器使用PHP 5.6我的Web服务器是wamp

代码:

$server_seed = "161293a556787ecaee5d04de72753323c916408f2f7f0cf2c1931717480d463c";
$lottery_id = "7606271363";
$round_id = "1";
$hash = hash("sha256", $server_seed . "-" . $lottery_id . "-" . $round_id);
$rolled_number = hexdec(substr($hash, 0, 8)) % 15;
echo "Round $round_id = $rolled_number";

0 个答案:

没有答案