tags:

views:

17

answers:

2

Hello,

I'm trying to learn PHP using netbeans although I've come up against a problem with the interpreter and I can't tell how to fix it.

It's to do with the notation <<<_END. It should, from what I'm learning wrap everything into a variable until it's ended with _END

However, if I plug in the following example:

<?php
        echo <<<_END 
        <html><head><title>PHP form upload</title></head><body><form method='post' action='upload.php' enctype='multipart/form-data'>
        Select File: <input type='file' name='filename' size='10' />
        <input type='submit' value='Upload'/>
        </form>

        _END

        if ($_FILES)
        {
            $name = $_FILES ['filename']['name'];
            move_uploaded_file($_FILES ['filename'][tmp_none], $name);
            echo "Uploaded image '$name' <br/> <img src='$name'/>";

        }
        echo "</body></html>";
        ?>

I get the following error message

Parse error: syntax error, unexpected T_SL in script.php on line 13, where line 13 is the code that says 'echo <<<_END'.

Can anyone help me, please?

+2  A: 

There must be no space/tab/indentation before ending _END like this:

       echo <<<_END 
        <html><head><title>PHP form upload</title></head><body><form method='post' action='upload.php' enctype='multipart/form-data'>
        Select File: <input type='file' name='filename' size='10' />
        <input type='submit' value='Upload'/>
        </form>
_END;

Don't forget that it is not allowed to indent the closing tag if you do so you will get a parsing error.

http://www.phpf1.com/tutorial/php-heredoc-syntax.html

Sarfraz
+2  A: 
  1. Missing semicolon after _END
  2. You can't have any indentation before _END
dev-null-dweller