By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

Question on using HTML within PHP documents

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.