Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 3:16 PM   #1
James
 
James's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

What is the best method for creating a Web Page that uses both
PHP and HTML ?

<HTML>
BLA
BLA
BLA
BLA
BLA


<?PHP
BLA
BLA
BLA
BLA
BLA
?>

</HTML>


OR

<?PHP
Echo "BLA"
Echo "BLA"
Echo "BLA"
Echo "BLA"
?>

OR

<?
Print "BLA"
Print "BLA"
Print "BLA"
Print "BLA"
?>

Thanks
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 3:16 PM   #2
Jamie Wright
 
Jamie Wright's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

> What is the best method for creating a Web Page that uses both
> PHP and HTML ?


There are a number of different ways of doing this, and I think your choice
really depends on how you would like to do it. My personal favourite is not
to include any HTML at all and just create PHP variables that contain my
HTML. Then at teh end of teh document I just use echo $output; This wouldn't
work so well in cases where you want to flush the output back to the user as
the script is being processed, but for short scripts this works well for me.

Jamie


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:16 PM   #3
Ian.H [dS]
 
Ian.H [dS]'s Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Mon, 30 Jun 2003 10:42:42 +0100, Kevin
Thorpe <kevin@pricetrak.com> amazingly managed to produce the
following with their Etch-A-Sketch:

> James wrote:
> > What is the best method for creating a Web Page that uses both
> > PHP and HTML ?

>
> If you are a programmer then you are probably happier staying
> inside the php tags and using print/echo to generate your HTML.
>
> I work differently. I write the bulk of my code at the top of the
> document then drop out of the php tags to output the html with as
> little php in there as possible. This lets me hand a rough but
> functional document to my colleague who styles and polishes it in
> DreamWeaver. If you take this a step further you can include the
> html to allow
> alternative languages / representations.
>
> <?php include('library.inc');
>
> loadobject($_REQUEST['id']);
> ?>
> <html>
> <body>
> <?=object['id']?>

^^^^^^^^^^^^^^^^^

> </body>
> </html>



And if the server is configured for XML (ie: short tags disabled)
this would fall over.

The biggest thing to strike me here for this example, was that you
use '<?php' for the initial instance, yet '<?' for the second.

One of the biggest parts of coding, is style and consistency =)



Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPwAPTmfqtj251CDhEQIE+QCglmHcOaBbjDscnB2gULebsd 4WfKcAoOWb
nW4s8jv0O0sEQzefYhiVYfpp
=hglr
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:16 PM   #4
Allodoxaphobia
 
Allodoxaphobia's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

On Mon, 30 Jun 2003 08:45:36 +0000 (UTC), James @ nothere.com (James) hath writ:
> What is the best method for creating a Web Page that uses both
> PHP and HTML ?


snip.....8<

All the previous comments are On Target.
Another point:
It Depends.
If you control the server, that's One Thing.
How-some-ever, on one server site where I `manipulate` some
web pages, .phtml and/or .shtml do not work for embedded
<$php tags. I have no recourse but to bundle each target
page up in a .php.

Jonesy
--
| Marvin L Jones | jonz | W3DHJ | OS/2
| Gunnison, Colorado | @ | Jonesy | linux __
| 7,703' -- 2,345m | config.com | DM68mn SK
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:16 PM   #5
Zach Nakaska
 
Zach Nakaska's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

James wrote:

> What is the best method for creating a Web Page that uses both
> PHP and HTML ?
>
> <HTML>
> BLA
> BLA
> BLA
> BLA
> BLA
>
>
> <?PHP
> BLA
> BLA
> BLA
> BLA
> BLA
> ?>
>
> </HTML>
>
>
> OR
>
> <?PHP
> Echo "BLA"
> Echo "BLA"
> Echo "BLA"
> Echo "BLA"
> ?>
>
> OR
>
> <?
> Print "BLA"
> Print "BLA"
> Print "BLA"
> Print "BLA"
> ?>
>
> Thanks


If you needed to output a lot of variables in the HTML, then I would suggest
echo. However, if it were only a few, then you could do:

<?
$variable = "value";
?>
<html><head></head><body>
<b><?= $variable ?></b>
</body></html>

--
Regards,
Zach Nakaska
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:16 PM   #6
Paul Liversidge
 
Paul Liversidge's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

Kevin Thorpe <kevin@pricetrak.com> wrote in message news:<3f0005d1$0$13006$afc38c87@news.easynet.co.uk >...
> James wrote:
> > What is the best method for creating a Web Page that uses both
> > PHP and HTML ?

>
> I work differently. I write the bulk of my code at the top of the
> document then drop out of the php tags to output the html with as little
> php in there as possible. This lets me hand a rough but functional
> document to my colleague who styles and polishes it in DreamWeaver. If
> you take this a step further you can include the html to allow
> alternative languages / representations.


My PHP "style" has evolved over a couple of years and it's taken on
this form with all the algorithm stuff at the top of the page before
the <head>. I then just drop in small bits of PHP in the HTML.

Using PHP to echo complex HTML is painful as you end up escaping all
the " and having 50 lines of $html .= "" is time consuming and the
layout is more fixed. If you stick to HTML you can still edit the
layout with Dreamweaver and I even use PHP to show/hide blocks of
HTML, i.e

<?
if ($displaythis) {
?>
<table ...
.... <td><?=$message?></td>
</table>
<?
} else {
?>
<table ...
.... <td><?=$message?></td>
</table>
<?
}
?>

This makes the whole process so much easier and seems to be the best
balance of HTML editability (with Dreamweaver) and power of PHP.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:16 PM   #7
Nigel Dunn
 
Nigel Dunn's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

James wrote:
> What is the best method for creating a Web Page that uses both
> PHP and HTML ?


I agree with both of the others that it all comes down to personal
style. I usually have my main pages as pure php control structures that
include various html files for outputing the data. This means that you
can open up both files in something like dreamweaver and edit them
independantly. Depends on the site, depends on your style.

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:17 PM   #8
Rob Allen
 
Rob Allen's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

In message <bf26a194.0306301335.43b6511a@posting.google.com>, Paul
Liversidge <paul_liversidge@hotmail.com> writes
>Using PHP to echo complex HTML is painful as you end up escaping all
>the " and having 50 lines of $html .= "" is time consuming and the
>layout is more fixed.


That's what

echo <<<EOT
<!-- my html goes here using ", '
and $variables as appropriate -->

EOT;

is for

>If you stick to HTML you can still edit the layout with Dreamweaver and
>I even use PHP to show/hide blocks of HTML, i.e


I do this too - the designers here use Dreamweaver and so I code my
pages to enable them to make amends without needing my input.

Rob...

--
Rob Allen
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:17 PM   #9
David Mackenzie
 
David Mackenzie's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

On 30 Jun 2003 14:35:27 -0700, paul_liversidge@hotmail.com (Paul
Liversidge) wrote:

>Kevin Thorpe <kevin@pricetrak.com> wrote in message news:<3f0005d1$0$13006$afc38c87@news.easynet.co.uk >...


>Using PHP to echo complex HTML is painful as you end up escaping all
>the " and having 50 lines of $html .= "" is time consuming and the
>layout is more fixed.


That's why I use ' instead of " for HTML attributes.

>If you stick to HTML you can still edit the
>layout with Dreamweaver and I even use PHP to show/hide blocks of
>HTML, i.e


I use CSS for layout which keeps the HTML simple and therefore my PHP,
too.

--
David (please modify address to david@ before replying!)
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 3:17 PM   #10
Ian.H [dS]
 
Ian.H [dS]'s Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Best Method using PHP & HTML ??

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Tue, 01 Jul 2003 16:16:03 +0100, David
Mackenzie <dcm@tarbrax.freeserve.co.uk> amazingly managed to produce
the following with their Etch-A-Sketch:

> On 30 Jun 2003 14:35:27 -0700, paul_liversidge@hotmail.com (Paul
> Liversidge) wrote:
>
> >Kevin Thorpe <kevin@pricetrak.com> wrote in message
> >news:<3f0005d1$0$13006$afc38c87@news.easynet.co.u k>...

>
> >Using PHP to echo complex HTML is painful as you end up escaping
> >all the " and having 50 lines of $html .= "" is time consuming and
> >the layout is more fixed.

>
> That's why I use ' instead of " for HTML attributes.



That's what the HEREDOC code is for


>
> >If you stick to HTML you can still edit the
> >layout with Dreamweaver and I even use PHP to show/hide blocks of
> >HTML, i.e

>
> I use CSS for layout which keeps the HTML simple and therefore my
> PHP, too.



Only fools use WYSINWYG editors.. regardless of how code is split up
=)



Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPwKlAWfqtj251CDhEQJHEACcDTvjsfiTSmzLMWeJuj0mpW RKJUsAnj26
sqZIfNt3rhLeWMqmtlcrOv/g
=GI7/
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
best method for simple web menu buckwheat Graphics in general 4 06-11-2007 8:06 PM
which connection method? Ben Database 2 05-31-2007 8:49 PM
Best payment method? Graham Ebay Technical Questions 0 05-30-2007 1:36 AM
Best payment method? Dave Ebay Technical Questions 0 05-30-2007 1:36 AM


Featured Websites




All times are GMT +1. The time now is 12:05 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98