Forum Moderators: coopster
-------------------------------------------------
The first method is:
<!--{PAGE_TITLE}-->
The second method is:
<title>#title#</title>
-------------------------------------------------
They both create a Key/Value array to assign the variables. In the first case it also creates the <title> tags. What I'm not clear on is if there is any significant difference between the two formats.
Another thing I'm not clear on is what I beleive is called a delimiter. The line of code appears as:
eval("?>".$this->template."<?");
It is the "?>" and "<?" that I'm not sure about. What do they represent and where can I find out more about what they do--(I've looked at php.net and googled, but couldn't find anything.)
On the second thing?> and <? normally start and stop php pharsing. The way it is used in your example seems really strange to me as the $this->template seems to be something from a class. What would print out if that was put on the net is exactly what you see between?> and <? ".$this->template."
PS.... if none of this makes sense I appoligize I just woke up... there may be some typoes as well
Both examples you gave are functionally equivalent.
This method is inefficient, it requires extra resources to accomplish. On a small to medium scale website it shouldn't be a problem though.
?> = Short tag, ends PHP and switches into HTML mode.
<? = Short tag to enter PHP mode.
A better option would be for the templates to be PHP files. They would still largely consist of straight HTML but instead of placeholders they would contain something like this:
<title><?=$title?></title>
This cuts out the step where the script is forced to parse the entire template looking for placeholders to replace on every page load.