Hi All,
I'm a new boy to php and working on a web site with long sections of
code that could be done as includes apart from one or two things
changing.
I've tested the following and it works, but what I really want to know
is am I OK placing php code inside a html line like this, or could there
be problems?
<!-- html code for test.php -->
<!-- lot of code cut -->
<a href="<?php print $filename; ?>"><?php print $title; ?></a>
<!-- lot of code cut -->
<!-- end of test.php -->
<!-- which is called in the main file like this -->
<?php
$filename="index.php";
$title="Index Page";
include ("test.php");
?>
--
Ken Ward in Norwich ke*@oldcity.f2s.com
For Norwich and East Anglia visit www.oldcity.org.uk 10 2088
Ken Ward wrote: Hi All,
I'm a new boy to php and working on a web site with long sections of code that could be done as includes apart from one or two things changing. I've tested the following and it works, but what I really want to know is am I OK placing php code inside a html line like this, or could there be problems?
<!-- html code for test.php --> <!-- lot of code cut --> <a href="<?php print $filename; ?>"><?php print $title; ?></a> <!-- lot of code cut --> <!-- end of test.php -->
<!-- which is called in the main file like this --> <?php $filename="index.php"; $title="Index Page"; include ("test.php"); ?>
Yeah I guess you're ok. You can actually use a shorter syntax to just print
a variable: <?= $varname ?>
I suspect someone will suggest you use some kind of template system that
separates your PHP from your HTML. Well, they have a lot of time on their
hands :)
..:A
-- http://www.ninja.up.ac.za
..:Ninja wrote: Yeah I guess you're ok. You can actually use a shorter syntax to just print a variable: <?= $varname ?>
This, however, will only work if the PHP directive "short_open_tag" is
se to On, and by default many hosts have it off.
--
Suni
In message <10***************@inet2.up.ac.za>, ".:Ninja"
<al**@it.up.ac.za> writes Ken Ward wrote:
Hi All,
I'm a new boy to php and working on a web site with long sections of code that could be done as includes apart from one or two things changing. I've tested the following and it works, but what I really want to know is am I OK placing php code inside a html line like this, or could there be problems?
<!-- html code for test.php --> <!-- lot of code cut --> <a href="<?php print $filename; ?>"><?php print $title; ?></a> <!-- lot of code cut --> <!-- end of test.php -->
<!-- which is called in the main file like this --> <?php $filename="index.php"; $title="Index Page"; include ("test.php"); ?> Yeah I guess you're ok. You can actually use a shorter syntax to just print a variable: <?= $varname ?>
I suspect someone will suggest you use some kind of template system that separates your PHP from your HTML. Well, they have a lot of time on their hands :)
Takes more time initially but probably saves it in the long term. .:A
--
Five Cats
Email to: cats_spam at uk2 dot net
".:Ninja" <al**@it.up.ac.za> wrote in message
news:10***************@inet2.up.ac.za... I suspect someone will suggest you use some kind of template system that separates your PHP from your HTML. Well, they have a lot of time on their hands :)
Oi! ;-)
Garp
"Five Cats" <ca*******@[127.0.0.1]> wrote in message
news:Ev**************@[127.0.0.1]... I suspect someone will suggest you use some kind of template system that separates your PHP from your HTML. Well, they have a lot of time on their hands :)
Takes more time initially but probably saves it in the long term.
I doubt it. Using a template system is a little like going back to using PHP
1--you get a far less powerful, less flexible system to work with.
I'm not saying that template systems are bad. People just need to remember
that their raison d'etre is to limit what can be done within a page. If that
is your requirment then it makes sense. Otherwise it can hardly be
advisable. The benefits of "separating presentation from logic" is abstract
and often times cosmetic, whereas the impact of bumping into a template
system limitation is very real.
In message <qo********************@comcast.com>, Chung Leong
<ch***********@hotmail.com> writes "Five Cats" <ca*******@[127.0.0.1]> wrote in message news:Ev**************@[127.0.0.1]... >I suspect someone will suggest you use some kind of template system that >separates your PHP from your HTML. Well, they have a lot of time on their >hands :) Takes more time initially but probably saves it in the long term.
I doubt it. Using a template system is a little like going back to using PHP 1--you get a far less powerful, less flexible system to work with.
I'm not saying that template systems are bad. People just need to remember that their raison d'etre is to limit what can be done within a page. If that is your requirment then it makes sense. Otherwise it can hardly be advisable. The benefits of "separating presentation from logic" is abstract and often times cosmetic, whereas the impact of bumping into a template system limitation is very real.
I would have said the reason for using a template (in the way I mean it)
is to make it easy to get a uniform page layout across a site.
--
Five Cats
Email to: cats_spam at uk2 dot net
"Chung Leong" <ch***********@hotmail.com> wrote in message
news:qo********************@comcast.com... "Five Cats" <ca*******@[127.0.0.1]> wrote in message news:Ev**************@[127.0.0.1]...I suspect someone will suggest you use some kind of template system
thatseparates your PHP from your HTML. Well, they have a lot of time on
theirhands :) Takes more time initially but probably saves it in the long term.
I doubt it. Using a template system is a little like going back to using
PHP 1--you get a far less powerful, less flexible system to work with.
I totally disagree. My system is based around an amalgamation of the 3 tier
architecture (refer to http://www.tonymarston.co.uk/php-mys...structure.html) and the
Model-View-Controller design pattern (refer to http://www.tonymarston.co.uk/php-mys...ontroller.html) and it
has proved to be very powerful and very flexible.
I'm not saying that template systems are bad. People just need to remember that their raison d'etre is to limit what can be done within a page. If
that is your requirment then it makes sense. Otherwise it can hardly be advisable. The benefits of "separating presentation from logic" is
abstract and often times cosmetic, whereas the impact of bumping into a template system limitation is very real.
I use XSL stylesheets to generate all my HTML and I have never found any
limitations. In fact my level of reusable code has gone up considerably
since using XSL. Take a look at http://www.tonymarston.co.uk/xml-xsl/reusable-xsl.html for details.
--
Tony Marston http://www.tonymarston.net
Chung Leong wrote: I'm not saying that template systems are bad. People just need to remember that their raison d'etre is to limit what can be done within a page. If that is your requirment then it makes sense.
Than it always makes sense. You see, you *must* limit what happens in a
page; specifically, the only thing that happens in a page is what is needed
to display it.
Everything else: database queries, calculations, text translations etc
should be done separately. When it comes to HTML, all data should already be
prepared for display. This is why templates are a good tool, despite their
performance penalty.
Berislav
--
If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.
"Berislav Lopac" <be************@dimedia.hr> wrote in message
news:c7**********@ls219.htnet.hr... Chung Leong wrote: I'm not saying that template systems are bad. People just need to remember that their raison d'etre is to limit what can be done within a page. If that is your requirment then it makes sense. Than it always makes sense. You see, you *must* limit what happens in a page; specifically, the only thing that happens in a page is what is
needed to display it.
I disagree with your emphasis on *must*. It is possible to write a component
which contains presentation, business and data access logic, but this does
not offer much opportunity for reusability. Personally I use a combination
of the 3 tier architecture and the Model-View-Controller design model to
produce a great deal of reusable code. However, the design and
implementation of such an infrastructure is beyond the capabilities of most
developers.
Everything else: database queries, calculations, text translations etc should be done separately. When it comes to HTML, all data should already
be prepared for display. This is why templates are a good tool, despite their performance penalty.
All my HTML is produced from XML data using XSL stylesheets. There may be a
performance overhead but the savings are made in short development times and
large amounts of reusable code.
--
Tony Marston http://www.tonymarston.net
Berislav
-- If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are Groucho, Chico, and Harpo, then Usenet is Zeppo.
"Berislav Lopac" <be************@dimedia.hr> wrote in message
news:c7**********@ls219.htnet.hr... Than it always makes sense. You see, you *must* limit what happens in a page; specifically, the only thing that happens in a page is what is
needed to display it.
Like handcuffs, the purpose of a template system is to limit what others can
do (page designers, end users, etc). You will never convince me that it's a
good idea to handcuff myself.
Everything else: database queries, calculations, text translations etc should be done separately. When it comes to HTML, all data should already
be prepared for display. This is why templates are a good tool, despite their performance penalty.
But you can easily keep these separate without resorting to a template
system--just don't mix them. I mean unless you are so undisciplined that you
need something to save yourself from yourself... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Atul Kshirsagar |
last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with
a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to
generate C++ to Python interface.
Now to...
|
by: Alicia Haumann |
last post by:
I accidentally sent this to webmaster@python.org, so this could be a
duplicate if "webmaster" forwards it to this list. :{
Hi, there.
Thanks for any help that can be offered. I've been...
|
by: Roose |
last post by:
With some googling I have found these resources:
http://docs.python.org/ext/win-dlls.html
http://www.python.org/doc/faq/windows.html
I have a large Win32/MFC/C/C++ application that has an...
|
by: alan b |
last post by:
I copied it and tried to edit the movie.htm below in the <PARAM NAME=***
location of the file where the videoclip is on my hard drive. It is already
recorded by Windows Media Player. My version...
|
by: Alan Lue |
last post by:
Hi,
I'm trying to set up a webpage so that I can view multiple HTML files
from the same page. For example, you might go to
http://example.com/lab_tests.html and be able to view lab1.html,...
|
by: John Dean |
last post by:
Hi
Could somebody, please tell me where I can find information about embedding
Python into a C/C++ application. The example in the docs is rather simple. I
am looking for something a bit more...
|
by: Qun Cao |
last post by:
Hi Everyone,
I am a beginner on cross language development. My problem at hand is to
build a python interface for a C++ application built on top of a 3D
game engine. The purpose of this python...
|
by: David Abrahams |
last post by:
I'm seeing highly surprising (and different!) behaviors of
PyImport_ImportModule on Linux and Windows when used in a program with
python embedding.
On Linux, when attempting to import a module...
|
by: mistabean |
last post by:
Hello,
first of all, I am a programming newbie, especially in python...
Onwards to the problem, I have been having difficulty embedding a
python module into my C/C++ program. (just a test...
|
by: John Grandy |
last post by:
I am not having success embedding carriage return and line feed characters
into a string and displaying them with an ASP.NET label. Is anyone getting
either of the following to work ?
...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |