JORd JORd - 7 months ago 22
PHP Question

cant print big strings in javascript with echo php

I have saved in my database some big string.. when I echo this string in php, it seems right, but when I echo in javascript something going wrong..
In javascript i use BigInteger.min.js and everything is right.

Actually when I do:

echo 'value: '.$row['number'].' <br> ' ;

I see:

value: 120118115121102112105113101111105118160154160166108115575502249857345147172085249

But when I try to do the same in javascript:

document.write(<?php echo $row['number'];?>);

I saw:


Please help me.


When not wrapped in quotes that "string" is handled as an integer. To have it display as a string wrap it in quotes in your code:

document.write("<?php echo $row['number'];?>");