Jump to content

PHP and HTML connection


lucerias

Recommended Posts

I am quite new to PHP, I saw many of PHP examples were coded like this, HTML is used for interface and structure design, PHP is used to process the input and then pass it to HTML and display the output. But can PHP do interface design without HTML help? I mean all the thing just do in PHP without HTML. If it is possible, then why do we follow the standard like that. Thank you.
Link to comment
Share on other sites

I think it's mainly down to personal taste.  One of the most important things I use PHP for is 'templates' (or including headers/footers/etc.).  This is a very powerful technique that allows you to effectively separate your script from your HTML.  Of course there's always some cross-over.

There are many PHP libraries that deal with such display abstraction.  You might want to have a look at [url=http://smarty.php.net/]Smarty[/url].
Link to comment
Share on other sites

[quote author=lucerias link=topic=114110.msg464134#msg464134 date=1162887154]
I am quite new to PHP, I saw many of PHP examples were coded like this, HTML is used for interface and structure design, PHP is used to process the input and then pass it to HTML and display the output. But can PHP do interface design without HTML help? I mean all the thing just do in PHP without HTML. If it is possible, then why do we follow the standard like that. Thank you.
[/quote]
No. PHP is a programming language and a web browser can not understand PHP. Browsers can only understand client side languages such as HTML, CSS, Javascript etc.  PHP is used as you said to process user input/to make you site dynamic etc.  If you use PHP you still need to use HTML in order for the browser to display your website when someone goes to it.
Link to comment
Share on other sites

[quote]No. PHP is a programming language and a web browser can not understand PHP. Browsers can only understand client side languages such as HTML, CSS, Javascript etc.  PHP is used as you said to process user input/to make you site dynamic etc.  If you use PHP you still need to use HTML in order for the browser to display your website when someone goes to it.[/quote]

For example, the browser can enter into URL/index.php and from here, we can code everything inside the .php or link with other .php, so why we still need html? Thank you.
Link to comment
Share on other sites

This a typical example from my web sites.  HTML code that's common to all pages in the web site, is either in Header or Footer.  So if I need to change something that effects all pages, I change it ONCE and I'm done.

[code]
<?php
$pgTitle = "Home Page";
include('header');

Show my page specific HTML content here.

include('footer');
?>
[/code]
Link to comment
Share on other sites

Your missunderstanding what php does and what html is.

[quote]so why we still need html?[/quote]

We dont, but without it your pages are just plain text. Html is the markup language (Hyper text markup language) used to markup data on the web.

Php just outputs strings, wether they contain html for use on the web, or are just plain text for use in other places.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.