html - Update php variable in head while writing in footer -
When I am creating my page, then I am updating the variable But when I am at the bottom of the page, I have found my last value for I have tried it with php looks like this: I agree with the comment about separation of logic, ideal situation When you write pages, you have all the information gathered beforehand ... However, as a quick improvement does not involve much refactoring, you can use output buffering Are: Although I'm suggesting the MVC pattern and implementing it in the frameworks ... it can save many headaches like this;) $ links Css refers to the link which the page's
& lt; Head & gt; Will be placed in the section.
$ links , instead of the end of the page
& lt; Head & gt; I want to be written in .
str_replace , but he writes it down below ..
& lt; Top & gt; & Lt ;? Php echo $ links; ? & Gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php included 'gallery.php'; $ Link = & Lt; Link type = "text / css" href = "/ css / lightbox.css"> ? & Gt; & Lt; / Body & gt;
& lt ;? Php ob_start (); ? & Gt; & Lt; Top & gt; PLACEHOLDER_LINKS & lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php included 'gallery.php'; $ Link = & Lt; Link type = "text / css" href = "/ css / lightbox.css"> ? & Gt; & Lt; / Body & gt; & Lt ;? Php $ html = ob_get_clean (); $ Html = str_replace ("PLACEHOLDER_LINKS", $ link, $ html); $ Echo echo;
Comments
Post a Comment