0

I came across a php function that returns an XSL sheet and was wondering what is "<<< eox" I get that the function returns the sheet I just haven't seen that "tag" before. Thanks!

sample:

function getStylesheetData() { 
return <<< eox
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
<xsl:template match="@* | node()">
   xsl functions...
</xsl:template>
</xsl:stylesheet>   
eox;
}

link to the question that I referenced for more info: PHP code to sort XML tags alphabetically?

Community
  • 1
  • 1

2 Answers2

2

That is the syntax for a heredoc string:

A third way to delimit strings is the heredoc syntax: <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation.

So in your example, the eox is just an identifier that can be replaced with something else.

Tim Cooper
  • 144,163
  • 35
  • 302
  • 261
1

It isn't EOX, it is just identifier and can be named anything. That syntax is know as heredoc. The prototype of it is:

<<< FOO
 some stuff here
 some more stuff here
FOO;

The important thing to notice when using heredoc syntax is that ending identifier (FOO; in above example) should not have any space/tab/indentation before it. For example:

// This will not work
    <<< FOO
    some stuff here
    some more stuff here
    FOO;

// This will work
    <<< FOO
    some stuff here
    some more stuff here
FOO;
Sarfraz
  • 355,543
  • 70
  • 511
  • 562