so I’m looking at another person’s code trying to fix it, and I’m not sure what is happening. I have a pretty strong knowledge of programming in general, but there is one line that is throwing me off. See below:
<?php
switch ($task) {
case "createDJ":
echo <<<END;
<h5>Create DJ Form</h5>
<!-- Code for DJ form goes here. -->
END;
break;
case "createShow":
echo <<<END;
<h5>Create Show Form</h5>
<!-- Code for Show form goes here. -->
END;
break;
//...
?>
What is going on with these END statements? I’ve never seen them before, Also, what is up with the <<< sign?
EDIT: Sorry about the syntax highlighting, not sure why it’s all messy.
EDIT: And now I understand why the syntax highlighting is messed up! haha
It’s not a statement, it’s a way of quoting a string.
It’s called called heredoc syntax, and it’s supposed to be a convenient way to quote a multi-line string.
<<<ENDstarts it andENDat the beginning of a line ends it. (ENDis the programmer’s choice, they can use an identifier they want.)This is explained here in the PHP documentation: