Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Muddled about different variable forms Storyman
I've been reviewing a couple of tutorials on building PHP template sides. Two of the tutorials write the variables in different ways and I was wondering if there is any difference.
The first method is:
The second method is:
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:
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.)
I am not real sure on the template thing, it looks to me like the first option is much more open on style so each page could look different but use the template. The second option since it has the <title> tag it seems like all you are entering is values into set formated tags this would cause all pages to look exactly the same only the data be different.
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 IanKelley
You're not actually looking at PHP... That's straight HTML with placeholders that a PHP script can go through and replace with variables.
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:
This cuts out the step where the script is forced to parse the entire template looking for placeholders to replace on every page load.
Thank you for clearing up the muddle. Your suggestion makes sense and greatly appreciated.