<<<_END isn't closing maybe </pre>( I think)

Hi everyone. I’m reading a book on php, attempting to teach myself php coding. I was instructed to use the following code. I should note that I’m writing this in Eclipse Kepler. When I used the <<<_END previously in my code, it worked fine. This time, however, the text remains blue afterward which i’m assuming is related to the <<<_END as deleting that line will restore the text color to its proper form.

I was hoping that someone here might be able to catch what I’m doing wrong or if it is just a formatting bug in eclipse. Thanks in advance.

[php]for($j = 0; $j < $row; ++$j)
{
$row = mysql_fetch_row($result);
echo <<<_END


Title $row[0]
Publisher $row[1]
SQU $row[2]
Price $row[3]
</pre>

<form action = "ConnectionTest.php" method = "post">
<input type = "hidden" name = "delete"	value = "yes" />
<input type = "hidden" name = "squ"	value = "$row[4]" />
<input type = "submit" value = "DELETE RECORD" />
 </form>
 
 _END;

}[/php]

I think it’s just formatting, you’re coding using HEREDOCS which I never used before…

I’m not saying it’s bad or anything, but most the code I seen in PHP don’t use HEREDOCS…

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Some say heredocs is cleaner, but I personally don’t like it.

Is the page being parse with WordPress or other template software?

Sometimes the underscore messes up due to other issues. Your code looks correct.

I would test it with <<<EOD or something more standard than an underscore and see if it works.

I do not use “eclipse”, have you looked at it in NotePad++ or even just plain NotePad to see if there
is something odd in hidden in the code?

I do agree with Topcoder. I never use HEREDOCS due to various issues with it. And, hard to follow
where the PHP is inside it. Try it without the underscore…

Thanks for the feedback everyone. I figured out what my problem was this morning. Eclipse placed _END; in a position where it was tabbed out a bit. Taking out the preceding white spaces worked like a charm.

Oh, yes, the EOL/EOT (end of line/end of text) has to be on it’s own line…

Well, sorry we had so much work to just remove a few spaces… Crazy!

Congrats on finding that…

Sponsor our Newsletter | Privacy Policy | Terms of Service