1

Trying to print out some html forms but I get a parsing syntax error. I believe it gets stuck on the SERVER[PHP_SELF] but I'm not sure. How can I get this to echo correctly?

Error occurs on the SERVER[PHP_SELF] line

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

function drawbuttons()
{

echo <<<EOT
<table>
<tr><td> 
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="previous" value="Previous" STYLE="font-size:12pt; background-color:00BFFF; color:ffffff">";
</form>
</td>
<td>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="next" value="Next"STYLE="font-size:12pt; background-color:00BFFF; color:ffffff">
</form>
</td></tr>
</table>
EOT;
}
2
  • You might want to reconsider how your question is worded. It sounds like you want to parse the syntax error in your html code as in you don't understand what it's trying to tell you. Consider: [HTML: "Parsing Syntax Error"] without the "[]". Commented Aug 1, 2010 at 20:12
  • Can you show the exact error message= It normally shows a line number, too, can you tell us what that line is in the code snippet= Commented Aug 1, 2010 at 20:14

2 Answers 2

3

From the manual on the heredoc syntax:

Heredoc text behaves just like a double-quoted string, without the double quotes. This means that quotes in a heredoc do not need to be escaped, but the escape codes listed above can still be used. Variables are expanded, but the same care must be taken when expressing complex variables inside a heredoc as with strings.

That means you can’t use PHP open or close tags and you need to use the proper syntax for variables. In this case use the curly brace syntax:

echo <<<EOT
<table>
<tr><td> 
<form action="{$_SERVER['PHP_SELF']}" method="post">
<input type="submit" name="previous" value="Previous" STYLE="font-size:12pt; background-color:00BFFF; color:ffffff">";
</form>
</td>
<td>
<form action="{$_SERVER['PHP_SELF']}" method="post">
<input type="submit" name="next" value="Next"STYLE="font-size:12pt; background-color:00BFFF; color:ffffff">
</form>
</td></tr>
</table>
EOT;
Sign up to request clarification or add additional context in comments.

Comments

1

You can't use PHP opening tags (short or not) inside heredocs.

Use instead:

<form action="{$_SERVER['PHP_SELF']}" method="post">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.