473,326 Members | 2,125 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,326 software developers and data experts.

Question on using HTML within PHP documents

As some of you who helped with my "No input file selected" query earlier
already know, I've just started a new job and am new to PHP.

All the webpages are PHP, but contain HTML as a string definition. Which is
actually nice and easy for me as I am an HTML specialist, but am a complete
newbie with PHP.

How inadvisable is it though?

Here's what I mean:

<?php

define('NAVBAR_TITLE', 'Shipping');

define('HEADING_TITLE', 'Shipping');

define('TEXT_INFORMATION', '
<table width="90%" border="0" cellpadding="5" height="339">
<tr>
<td
width="20%">&nbsp;</td>
<td width="51%">
<p><font
size="7" face="Verdana, Arial, Helvetica, sans-serif"><b>Don\t know if this
is a good idea</b></font> ..........etc
........

Basically - any HTML can go here, as long as it\'s within a table, and
apostrophes are preceded by a backslash - as I have done above with the word
&quot;it\'s&quot;
</table>

');
?>
Basically, it's just HTML that is copied and pasted into a
define('TEXT_INFORMATION', ' string '

Which is why it ends
');
?>
What are the perils that could face me by continuing to write pages in this
fashion? Could it cause accessibility problems on some browsers?

I know it's terribly lazy but I have an awful lot of work to do and not
enough time just yet to learn good PHP skills.

Jun 16 '06 #1
5 3745
by default php will output your html as normal if you close the tags.
So instead of define('TEXT_INFORMATION', '
with all yoru code just close the tag
?>
and write it like normal HTML. If its not inside the tags its not
parsed.

Also if you have dynamic content you want to include a quick was is
this

<div>This is <?= $name ?>'s DIV tag, isnt it cool </div>

<?= ?> works as a quick echo of whatever follows the =
Tristán White wrote:
As some of you who helped with my "No input file selected" query earlier
already know, I've just started a new job and am new to PHP.

All the webpages are PHP, but contain HTML as a string definition. Which is
actually nice and easy for me as I am an HTML specialist, but am a complete
newbie with PHP.

How inadvisable is it though?

Here's what I mean:

<?php

define('NAVBAR_TITLE', 'Shipping');

define('HEADING_TITLE', 'Shipping');

define('TEXT_INFORMATION', '
<table width="90%" border="0" cellpadding="5" height="339">
<tr>
<td
width="20%">&nbsp;</td>
<td width="51%">
<p><font
size="7" face="Verdana, Arial, Helvetica, sans-serif"><b>Don\t know if this
is a good idea</b></font> ..........etc
.......

Basically - any HTML can go here, as long as it\'s within a table, and
apostrophes are preceded by a backslash - as I have done above with the word
&quot;it\'s&quot;
</table>

');
?>
Basically, it's just HTML that is copied and pasted into a
define('TEXT_INFORMATION', ' string '

Which is why it ends
');
?>
What are the perils that could face me by continuing to write pages in this
fashion? Could it cause accessibility problems on some browsers?

I know it's terribly lazy but I have an awful lot of work to do and not
enough time just yet to learn good PHP skills.


Jun 16 '06 #2
Tristán White schrieb:
Could it cause accessibility problems on some browsers?

I know it's terribly lazy but I have an awful lot of work to do and not
enough time just yet to learn good PHP skills.


Hi

Browsers just get the output of the script - they dont care how it is
generated so if there are any browser-problem they are also in your
HTML-only-code.

Many people separate HTML and PHP-Code because its easier to maintain.
However - its your choice. Visitors will not see a difference

Florian
Jun 16 '06 #3
Message-ID: <C0******************@charitiesadvisorytrust.org.u k> from
Tristán White contained the following:
All the webpages are PHP, but contain HTML as a string definition. Which is
actually nice and easy for me as I am an HTML specialist, but am a complete
newbie with PHP.
Cool, an HTML specialist :-)
....

<table width="90%" border="0" cellpadding="5" height="339">
<tr>
<td
width="20%">&nbsp;</td>
<td width="51%">
<p><font
size="7" face="Verdana, Arial, Helvetica, sans-serif"><b>Don\t know if this
is a good idea</b></font> ..........etc


That's so last century...
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jun 16 '06 #4
adlerweb wrote:

Browsers just get the output of the script - they dont care how it is
generated so if there are any browser-problem they are also in your
HTML-only-code.

Many people separate HTML and PHP-Code because its easier to maintain.
However - its your choice. Visitors will not see a difference


It *does* matter. Program code isn't written for computers to understand -
its written for people to understand. This kind of thing makes maintaining
the code very difficult and fraught with errors. You don't need a
templating system to seperate the HTML from the application logic - but
that doesn't mean you SHOULDN'T seperate the two.

C.

Jun 16 '06 #5
Agree with Colin, why bother doing something if you don't do it right.
If your company is anything like mine 3-4 months down the road (just
when you forget what you did) a user will ask for an upgrade and youll
be stuck trying to figure out what you did or why the hell you did it
that way.

Colin McKinnon wrote:
adlerweb wrote:

Browsers just get the output of the script - they dont care how it is
generated so if there are any browser-problem they are also in your
HTML-only-code.

Many people separate HTML and PHP-Code because its easier to maintain.
However - its your choice. Visitors will not see a difference


It *does* matter. Program code isn't written for computers to understand -
its written for people to understand. This kind of thing makes maintaining
the code very difficult and fraught with errors. You don't need a
templating system to seperate the HTML from the application logic - but
that doesn't mean you SHOULDN'T seperate the two.

C.


Jun 16 '06 #6

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

Similar topics

2
by: Martin Lucas-Smith | last post by:
I am trying to use PHP's COM support to open a URL from within MS Word then save the document. I am using PHP5.0.3/Apache2/WindowsXP. phpinfo() confirms that COM support is enabled. ...
28
by: petermichaux | last post by:
Hi, On my computer apache will see php in .php documents but not in .html documents. Can I configure apache to see php in .html documents? Or is this something that cannot be done at all? ...
1
by: Jon Noring | last post by:
I am considering a custom URI scheme which identifies various resources, such as id's, within a coherent set of multiple XML documents using the query component. I was told that the syntax I'm...
5
by: Neville310 | last post by:
I have a few questions about the name attributes and href referencing to. Can you declare name attributes for tags other than anchor elements (like div or h2)? The validator keeps returning the...
1
by: Bill H | last post by:
I am a beginner programmer taking my first VB 6.0 class, please forgive me if this question is foolish. Question: How is XML (Extensive Markup Language) a part of the .NET environment and is...
2
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
10
by: serge calderara | last post by:
Dear all, I need to build a web application which will contains articles (long or short) I was wondering on what is the correct way to retrive those article on web page. In orther words, when...
15
by: dn | last post by:
I'm starting an n-tier application with an ASP.NET 2.0 presentation layer, a business layer, a data access layer, and a SQL Server 2005 database, and I have a question. In the business and data...
32
by: Next | last post by:
Hi folks, Years ago, it occurred to me that a lot of the trouble of writing web browsers is caused by the upside-down arrangement of things: Javascript code exists inside a document, when...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
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....
0
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
0
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 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.