...

View Full Version : Resolved PHP Noob having trouble with error message



sirkuddles
01-27-2010, 04:04 AM
Hello, all :)

I am completely new to PHP, and am enrolled in an online PHP class. So far I love PHP, but I can already tell it would be much more easily learned from a real life, flesh and blood teacher.

Anyways, I am working on a simple homework assignment that asks me to code a Web page that echos text using the "here document" syntax. The textbook basically gives me the code to copy into my own file, which I have done, but after loading my completed code in a browser I get the error:

"Parse error: parse error, expecting `T_VARIABLE' or `T_END_HEREDOC' or `T_DOLLAR_OPEN_CURLY_BRACES' or `T_CURLY_OPEN' in C:\Web\www\Chapter.02\Aquaculture.php on line 22"

My code is:


<!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">
<head>
<title>Aquaculture</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Aquaculture</h1>
<?php
echo <<<HERE
<p>According to the online edition of the Columbia Encyclopedia,
<strong>aquaculture</strong> is the raising and harvesting of
fresh and saltwater plants and animals. The most economically
important form of aquaculture is fish farming, an industry that
accounts for nearly 20% of world fisheries production, and is
steadily increasing its share.</p>
HERE;
?>
</body>
</html>


Any help would be greatly appreciated!

Also, if anyone would like to recommend some useful PHP tools to a complete beginner, that would also be nice. I am currently using EasyPHP and Notepad++ to do everything.

Thanks!

bdl
01-27-2010, 04:11 AM
PHP manual : Types : Strings : heredoc (http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc)



It 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.


Bookmark the PHP Language Reference (http://us2.php.net/manual/en/langref.php) and read it thoroughly. Best resource for learning PHP, IMHO.

I personally do everything in either gEdit or Edit+, depending on the platform. Get to learn the language before you jump to an IDE.

Len Whistler
01-27-2010, 04:14 AM
Too much white space. perhaps tabs. I like GEDIT on Linux.


<!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">
<head>
<title>Aquaculture</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Aquaculture</h1>
<?php

echo <<<HERE
<p>According to the online edition of the Columbia Encyclopedia,
<strong>aquaculture</strong> is the raising and harvesting of
fresh and saltwater plants and animals. The most economically
important form of aquaculture is fish farming, an industry that
accounts for nearly 20% of world fisheries production, and is
steadily increasing its share.</p>
HERE;
?>
</body>
</html>

sirkuddles
01-28-2010, 08:20 PM
Thanks for the advice bdl. I am already finding the manual to be of great use.

Thanks also to Len. My code is up and running perfectly now. My textbook failed to inform me of the fact that white space could not be used with closing identifiers.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum