homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Muddled about different variable forms

10+ Year Member

Msg#: 4962 posted 4:58 pm on Sep 4, 2004 (gmt 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.)



10+ Year Member

Msg#: 4962 posted 8:00 pm on Sep 4, 2004 (gmt 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


WebmasterWorld Senior Member 10+ Year Member

Msg#: 4962 posted 12:16 am on Sep 5, 2004 (gmt 0)

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.


10+ Year Member

Msg#: 4962 posted 1:29 am on Sep 5, 2004 (gmt 0)


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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved