Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Muddled about different variable forms

4:58 pm on Sep 4, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Jan 4, 2004
votes: 0

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.)

8:00 pm on Sept 4, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
votes: 0

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

12:16 am on Sept 5, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 4, 2001
votes: 13

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.

1:29 am on Sept 5, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Jan 4, 2004
votes: 0


Thank you for clearing up the muddle. Your suggestion makes sense and greatly appreciated.