473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

<%something%> in html templates

I have a number of basic PHP books but they don't cover passing variables
into an HTML template which is called into a PHP script. (I am trying to
keep the mark-up and the execution code seperate.)

I have seen <%something%> in an html template page but I am trying to work
out how this value is passed.

What is this process called? I am sure there must be a lot of online
tutorials covering this but I don't seem to be entering the correct search
criteria. If I can create just a simply one, then I will be able understand
what is happening.

Thanks in advance of any help or useful links.

Cheers

Phil

(ps. apologies if you spotted this erroneously posted in alt.php.sql earlier
this afternoon.)


Jul 17 '05 #1
5 1508
Hi,
I have not seen your code but there are 4 very popular methods of
passing values from one page to the other.

1. $_GET['varname'];
2. $_POST['varname'];
3. $_SESSION['varname'];
4. $_COOKIES['varname'];

so you have to spot these and then search for it.

I strongly feel that in your case it will be GET or POST as they are
basic and SESSION and COOKIES are a little advanced.

Hope this helps,
Bye

Jul 17 '05 #2
In a nutshell, a script will open this template file and do a search
and replace.
So, "parsed", rather than "passed" might be a better word to describe
what's happening.

Jul 17 '05 #3
BKDotCom (bk***********@yahoo.com) wrote:
: In a nutshell, a script will open this template file and do a search
: and replace.
: So, "parsed", rather than "passed" might be a better word to describe
: what's happening.

google: php template
--

This space not for rent.
Jul 17 '05 #4
Hmm.. not sure exactly what it is you've seen. There are a number of
templating systems out there like Smarty (http://smarty.php.net) or
PEARs Template_IT (http://pear.php.net/package/HTML_Template_IT). In
most templating systems, you set the variables in the page code then
call the template when you are ready to display:

<?
// this is example code - not specific to anything
$template = new Template("/path/to/template.tpl");
$foo = "Hello";
$template->set_value("foo", $foo);
$template->display();
?>

and the template would contain something like this:

<html>
<body>
<strong>{foo}</strong>
</body>
</html>

The other thing you may be thinking of is just outputting php variables
within html. For example, you could have a script like this:

<?
$foo = "hello";
include("template.php");
?>

template.php:
<html>
<body>
<strong><?=$foo?>
</body>
</html>

<?=$variable?> prints the contents of the variable.

The <% .. %> are tranditional ASP tags but i know that some template
systems are configured to use them.

Sorry for the vauge rambling - i hope it helps :0)

Steve

Jul 17 '05 #5
In most cases it is done in a html file where **** (some string) is
replaced with your variable. If it is a simple one the strreplace is
enough, but for more complicated cases preg_* and ereg_* would be
necessary.

See some simple examples of these functions in php.net's manual (preg*
& ereg*) to get the idea of the realiztion of a template system.

Best regards.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: seberino | last post by:
Tuples are defined with regards to parentheses ()'s as everyone knows. This causes confusion for 1 item tuples since (5) can be interpreted as a tuple OR as the number 5 in a mathematical...
1
by: GHUM | last post by:
I have found a "make a icon in traybar" skript, and it loads its Icon from a file hinst = win32gui.GetModuleHandle(None) iconPathName= "c:/myapp/myapp.ico" icon_flags =...
0
by: vinod | last post by:
Dear Experts, I'm vinod, a happiest member of this forum, i've another doubt please explain me what is information_schema.<table> i'm using this to get some information from database. but i didnt...
4
by: Christopher Pisz | last post by:
I've seen this alot. I imagine the "I", stand for interface. Usually I see two files: SomeClass.h ISomeClass.h Can someone explain this practice and what the differance between the two files...
5
by: Osamede Zhang | last post by:
I just can't understand what appSettings means, how it work thanks for your read osamede
0
by: jfarr | last post by:
Hi all, I must be missing some syntax here, but for the life of me I cannot figure out what it might be. Here is my query; System.Management.ObjectQuery oQuery = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.