473,655 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<%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 1525
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("templa te.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
3331
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 expression such as x = (5) * (4+6). Wouldn't it have been better to define tuples with <>'s or {}'s or something else to avoid this confusion?? Perhaps ()'s are a good idea for some other reason I don't know?
1
2610
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 = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE hicon = win32gui.LoadImage(hinst, str(iconPathName), win32con.IMAGE_ICON, 0, 0, icon_flags) that works great.
0
1279
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 have good idea what exactly it is. please tell me thanks in advance
4
1307
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 should be?
5
1434
by: Osamede Zhang | last post by:
I just can't understand what appSettings means, how it work thanks for your read osamede
0
1068
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 System.Management.ObjectQuery("Select Name, DisplayName from Win32_Service where DisplayName LIKE 'Rescue%' "); Can anyone see what I am doing wrongly here????? Thanks
0
8380
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8710
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.