Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Exclamation PHP Noob having trouble with error message

    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:
    Code:
    <!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!
    Last edited by sirkuddles; 01-28-2010 at 07:16 PM.

  • #2
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    PHP manual : Types : Strings : heredoc

    Quote Originally Posted by PHP Manual
    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 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.

  • #3
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Too much white space. perhaps tabs. I like GEDIT on Linux.

    PHP Code:
    <!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>
    Leonard Whistler

  • Users who have thanked Len Whistler for this post:

    sirkuddles (01-28-2010)

  • #4
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •