I have a code that sends a long integer from PHP to Javascript.
When I send the 13546000000512023 value, Javascript saves 13546000000512024.
But for other values works.
PHP: 13546000000512022, Javascript: 13546000000512022
PHP: 13546000000512024, Javascript: 13546000000512024
<script>
function setIdPost(data) {
console.log(data);
}
setIdPost(<?= $_GET["id"]; ?>);
</script>
<?= $_GET["id"]; ?>
It works when I send the value as a string
setIdPost("<?= $_GET["id"]; ?>");
Why is this happening? I tried in multiple browsers.
I know that these numbers are bigger than Number.MAX_SAFE_INTEGER (9007199254740991). But, Why some of them works and others not?