I installed a class that is simplified:
class Labels { static public $NAMELABEL = "Name"; }
I successfully got the following code to work fine:
echo '<table border="1">'; echo '<tr>'; echo "<th>" . Labels::$NAMELABEL . "</th>"; echo '</tr>'; // the rest of the Table code not shown for brevity... echo "</table>";
I see a table with a column heading called Name when I run it, so it works fine.
But not inside heredoc - I get "Note: Undefined variable: NAMELABEL in C: \ xampp ........ blah blah" when I run the following:
echo <<<_END <form action="index.php" method="post"><pre> Labels::$NAMELABEL : <input type="text" name="author" /> <input type="submit" value="ADD RECORD" /> </pre></form> _END;
I tried all kinds of quotes, the string operator concat '.', Nothing works. I realized: "Well, I got static class variables to work in an HTML table, why not heredoc."
Dang I love heredocs, they come with a strange name and strange problems. This is the kind of funny look that I crave, heredocs the righteous little doosh monkeys.
I really want to use my static class variables here - is there some sort of quote / string concatenation combination that will allow me to embed them in my heredocs?
wantTheBest
source share