Getting syntax error, pls help

Hi,

I am new to PHP, started learning it by myself.

I wrote a very simple PHP code and it is giving an error “Parse error: syntax error, unexpected $end in C:\xampp\htdocs\process_story.php on line 28”. Actually the code ends at line 27.

There are no curly braces used in my code. And I used <?php but not <?.

Pls have a look at my code.

This is your story

Little Boy Who?

<?php $color = filter_input(INPUT_GET, "color"); $instrument = filter_input(INPUT_GET, "instrument"); $animal = filter_input(INPUT_GET, "animal"); $another_animal = filter_input(INPUT_GET, "another_animal"); $one_more_animal = filter_input(INPUT_GET, "one_more_animal"); $place = filter_input(INPUT_GET, "place"); $vegetable = filter_input(INPUT_GET, "vegetable"); $structure = filter_input(INPUT_GET, "structure"); $action = filter_input(INPUT_GET, "action");
	print <<<STORY
	Little boy $color, come blow your $instrument ! <br />
	The $animal in the $place, the $another_animal in the $vegetable <br />
	Where is the boy that looks after the $one_more_animal? <br />
	He is under the.
	STORY;
?>

Pls help me on what could be the reason for this error.

You are using ‘heredoc’ string, but it looks like you also have indents for your entire php code. Here is what doc says:

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 [i][b]may not be indented[/b][/i], and there may not be any spaces or tabs before or after the semicolon.

(Source: http://php.net/manual/en/language.types.string.php)

Hi,

Thank you! The error has gone.

Actually I came across the note about the closing identifier for heredoc string. But ‘indentation’ didn’t strike me at all.

Thanks once again !

Sponsor our Newsletter | Privacy Policy | Terms of Service