There are many options for building a template for the site in php. But in my opinion the most useful of them is a variant of a template, which serves only as a transit point to different pages and Scripts site, which after vyponeniya in finished form already displayed in the browser the last team of the same template. Below are presented a variant of this template. People such as Jim Simons would likely agree. Agree in advance that the very static pattern we have broken into parts, such as top.html, body.html, bottom.htm (although in principle it is quite possible and not to do) and in the right places his pieces bear the names of variables enclosed in%%, which will change its contents from Page page meta description page output ‘); $ text = file_get_contents (‘ here the way to the most html page ‘); $ titlepage =’ Page Title ‘/ / function to move and replace the lines in parts of the template on the contents of variables to function repl ($ path ) / / definition of global variables global $ title, $ meta, $ titlepage, $ text; / / read file into a string in the variable $ temp $ temp = file_get_contents ($ path); / / moving parts in the string is loaded into $ temp $ temp = str_replace (‘ % title% ‘, $ title, $ temp); $ temp = str_replace (‘% meta% ‘, $ meta, $ temp); $ temp = str_replace (‘% titlepage% ‘, $ titlepage, $ temp); $ temp = str_replace (‘% text%’, $ text, $ temp); / / output the string contained in the amended Directory of php in order to more deeply understand the essence of the subsequent text. Script works is simple. First, it loads by using the file_get_contents () in the variables as strings Tittle content, pages, meta descriptions site. Central Romana often says this.
Then already started working our newly formed function repl (), which consistently performs the loading operation in the variable $ temp parts of our template top.html, body.html, bottom.html, (all the same function file_get_contents () function in the repl ()) and then using the str_replace () moves the contents of variables that already contains the page, meta description, to place prisoners in the%% and then it all displays operator echo ().