Search code examples
phpclasshtmldoc

How to reference a static variable in a HTMLDOC content in PHP


How can I use a

templateize::$subject

in a

$html = <<<HTMLDOC
abc+abc+ab templateize::$subject

HTMLDOC;

in a HTMLDOC content?


Solution

  • The docs are here.

    The code looks like this:

    <del>

    $html = <<<HTMLDOC
    abc+abc+ab {${templateize::$subject}}
    
    HTMLDOC;
    

    </del>

    Actually, that's not quite true. If templateize::$subject == "foo", the above will be interpreted as {$foo}.

    I can't seem to find a possibility to achieve, what you want, except from this:

    $foo = templateize::$subject;
    
    $html = <<<HTMLDOC
    abc+abc+ab $foo
    
    HTMLDOC;