Character limit of a javascript string variable

前端 未结 3 670
无人及你
无人及你 2021-02-19 00:36

Can JavaScript string store 100K characters? I\'ve written a script where a string from PHP is passed to a variable in JavaScript. It works fine when it is cut short to almost

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 01:14

    There is no theorical limit to JS or PHP on the size of their strings.

    I think there are a few possible situations.

    Firstly, check that you are not sending your string via HTTP GET. There is a maximum size for GET and i think its dependent on your web server.

    Secondly, if you do use POST, check in php.ini for post_max_size and see if it is smaller than the string size you are sending to it as well as your .htacccess file to see if php_value post_max_size is not too small.

    Thirdly, check that in php.ini that your memory_limit does not restrict the size of memory that your script can use.

    hope this helps.

提交回复
热议问题