larka06 Posted August 26, 2013 Share Posted August 26, 2013 To me the parse error suggests that there is a missing semi-colon or quotation something like that but I can not find a single case of not having matches. As for the regular Expressions I know nothing so I just copied out of the book. I have been over them several times and all seems right. I have comments where I know that the unreconition begins. Here is the parser statement then the code..... Parse error: syntax error, unexpected $end in sort_words_by_length.php on line 71. There is only 70 lines. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Sorting words in a block of text by length</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Geany 0.21" /> <link href="common.css" rel="stylesheet" type="text/css"/> </head> <body> <h1>Sorting words in a block of text by length</h1> <?php $myText = <<<END_TEXT But think not that this famous town has only harpooners, cannibals, and bumpkins to show her visitors. Not at all. Still New Bedford is a queer place. Had it not been for us whalemen, that tract of land would this day perhaps have been in as howling condition as the coast of Labrador. END_TEXT; echo "<h2>The text:</h2>"; echo "<div style=\"width: 30em; \">$myText</div>"; $myText = preg_replace("/[\,\.]/", "", $myText); $words = array_unique(preg_split("/[\n\r\t]+/",$myText)); usort($words, create_function('$a,$b', 'return strlen($a) - strlen($b);')); echo "<h2>The sorted words:</h2>"; echo "<div style\"width: 30em; \">"; foreach ($words as $word) { echo "$word "; } // Is teamed with above echo "</div>"; // Not sure about reconition. ?> //Not gettting reconized <p><a href="http://httpd.apache.org/"><img src="/icons/apache_pb2.gif" alt="[ Powered by Apache ]"/></a> </body> //Not gettting reconized </html> //Not gettting reconized. Line 70. Quote Link to comment Share on other sites More sharing options...
Solution kicken Posted August 26, 2013 Solution Share Posted August 26, 2013 $myText = <<<END_TEXT But think not that this famous town has only harpooners, cannibals, and bumpkins to show her visitors. Not at all. Still New Bedford is a queer place. Had it not been for us whalemen, that tract of land would this day perhaps have been in as howling condition as the coast of Labrador. END_TEXT; HEREDOC Syntax WarningIt is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon ( . That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including Mac OS X. The closing delimiter (possibly followed by a semicolon) must also be followed by a newline. If this rule is broken and the closing identifier is not "clean", it will not be considered a closing identifier, and PHP will continue looking for one. If a proper closing identifier is not found before the end of the current file, a parse error will result at the last line. Quote Link to comment Share on other sites More sharing options...
larka06 Posted August 26, 2013 Author Share Posted August 26, 2013 I have no spaces after ether the beginning <<<END_TEXT or the botttom END_TEXT. I am sure that the problem is down in the lower part. as you can see I have marked the ones not recognized. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted August 26, 2013 Share Posted August 26, 2013 let me try this one... ...That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. I'm pretty sure Kicken is a hella lot better at this kind of thing than you are. What is the point of asking for help if you will not listen to the answer? Quote Link to comment Share on other sites More sharing options...
larka06 Posted August 26, 2013 Author Share Posted August 26, 2013 Sorry I was so thick I missed the whole point. No excuse just late and tired. I just changed the indentation and now it works. Many thank for both of you. I guess I needed the scolding to get my attention. As for Kicken being better I am sure he is. I am a real newbie trying to teach myself. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.