How long can a string be?
Posted by enquirer (enquirer), 17 March 2003I'm looking for the answer to this question that I found at a quiz site. It says you would know the answer.I have a text string that is 58,880 text characters long and when I try to run my PHP script I get an error that says 'expecting "," or ";" on line 12...' which is only 8 lines into my 650+ line variable definition. I found a few PHP forums with the same question but the answer is usually 'There shouldn't be a limit'.
PHP Programming quiz, level Basics, question 13
Posted by admin (Graham Ellis), 17 March 2003The answer (Quiz site) is "no practical limit" and indeed I have often worked with strings that are far longer than 60k.. It could be that there's a lower limit for the " operator or the ' for a literal string, or perhaps you have one of those characters actually in your string?
a) Check your string for " or ' embedded in it
b) Build up your string using . (period) operators from a series of shorter strings.
The quiz site mentioned - http://www.phpquiz.co.uk is one of "ours" by the way - so I'm able to quote / post from it here at will without any copyright problems
Posted by enquirer (enquirer), 17 March 2003Thanks for the quick response. It was actually another simple syntax error that had nothing to do with the string itself. My editor uses word wrap but still numbers the lines, although PHP sees all 650+ lines as just one, so my real problem WAS on line 12 when i took word wrap off.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho