Using PHP variables inside of here documents inside of functions inside of a class -


If the title has not scared you yet, read it. I am working on an expression engine website and am editing member template file. All templates related to member contact are stored in a single file as functions inside the class.

Each of these functions is a simple document, but many of them are printed with path codes and rules do not care to use. For example, this website instead of "subscribers" Will be referred to as log-in.

Still, I am exploring a way to summarize these values ​​so that I can easily change them and future projects, right now, I am able to print the variable within these documents

Pre> & lt ;? Php / * I want to define variables once in this field / / $ globaluserterm = "client"; Class profile_theme {// ---------------------------------------- // member page externally // ---------------------------------------- function member_page () {$ userterm = "Customer"; Return & lt; & Lt; & Lt; EOF & lt; Div id = "{$ userterm} -content" & gt; & Lt; H1 & gt; {$ Userterm} account & lt; / H1> (Note: this works) & lt; H1 & gt; {$ Globaluserterm} account & lt; / H1> (Note: this does not work) (includes: member_manager) & lt; / Div & gt; EOF; } / * END * / // ------------------------------------- // Full Proxy With menu // ------------------------------------- function full_profile () {$ userterm = " Customer "; Return & lt; & Lt; & Lt; EOF & lt; Div id = "{$ userterm} -fun-profile" & gt; {Include: Content} & lt; / Div & gt; EOF; } / * END * /} // END class? & Gt;

If you have only one category per file, then it may already be defined Is enough to assume square level? E.g.

  class profile_theme {personal $ globaluserterm = "customer"; // ....}  

and in the function:

  back  & Lt; & Lt; EOF & lt; Div id = "{$ userterm} -content" & gt; & Lt; H1 & gt; {$ Userterm} account & lt; / H1> (Note: this works) & lt; H1 & gt; {$ This- & gt; GlobalAuserum} account & lt; / H1> (Note: this does not work) (includes: member_manager) & lt; / Div & gt; EOF;  

Comments