开发者

NetBeans does not recognise <<<_END

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='multipa开发者_如何转开发rt/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?


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


  1. Missing semicolon after _END
  2. You can't have any indentation before _END
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜