Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
How long can a string be?

Posted by enquirer (enquirer), 17 March 2003
I'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
Quote:
Question: The maximum length of a string held in a variable is ...
Answer 1: There is no practical limit
Answer 2: 1024 bytes
Answer 3: 10240 bytes
Answer 4: Just under 4 Megabytes


Posted by admin (Graham Ellis), 17 March 2003
The 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?  

Solutions ...
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 2003
Thanks 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.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho