Html/Php Information

by 12 replies
14
Alright guys

At the moment I am totally confused to the differences between HTML and PHP.. Does it really matter if I just create my websites in HTML format?? What are the benifits of creating a site in PHP format please?


Also if I have create my files in HTML is there any way that I can change them to PHP and have no issues in the long run? Or is that easy to change the extension from HTML to PHP??
#programming #html or php #information
  • HTML is a static language, whereas PHP is dynamic.

    By that I mean PHP can access databases, can determine validate email addresses entered in a text box (for example), can connect to xml feeds and create new content. PHP and HTML are used together to create sites that change and show different information according to what the visitor does.

    HTML (without PHP) is used to create a site that doesn't change. It will always be the way you designed it. You can click on links to show different pages.

    I'll show you an example.

    Code:
    <html>
    <head>
    <title>Hello World</title>
    </head>
    <body>
    <h2>Hello World</h2>
    </body>
    </html>
    This is html. It simply displays 'Hello World' in the title and as a heading on the page.

    Code:
    <?php
       
       $ name = 'Dave';
    ?>
    <html>
    <head>
    <title>Hello <?php echo $ name; ?></title>
    </head>
    <body>
    <h2>Hello <?php echo $ name; ?></h2>
    <?php
       if ($ name=='Michael') {
          echo "<p>Thats a great name</p>";
       } else {
          echo "<p>How common</p>";
      }
    ?>
    </body>
    </html>
    This is HTML with PHP in it. At the top I define a variable $name and give it the value 'Dave'. (I've had to put a space between the $ and name as the forum was removing the whole variable!) I display 'Hello Dave' as the heading and the page title. Then below it I check to see if that name is 'Michael'. If it is I display 'Thats a great name' otherwise I display 'How common'.

    So you should be able to see how PHP can make an otherwise static page change according to variables.

    If you're happy with a static site, there's no reason for you to put PHP into the html.

    Hope that helps!

    Mike
    • [ 1 ] Thanks
  • My advice is that if you think it is possible that at anytime in the future you might want to implement any php on your site, name your files with .php extension from the get go.

    You can create them with pure html and still use the .php file names.

    I had sevearl sites that used .html file names and eventually used php includes for headers and menus etc. For a while I got away with some code in .htaccess that let the php work on html file pages.

    However, some changes were made in server file updates that stopped that from working and I had to rename thousands of pages and do redirects for all of them.

    Lesson learned...use .php from the start on all new sites.
  • CBSnooper thanks for the explanation.. All though i have php knowledge but i don't have any ideals about it... for all you have impart something in my Brain.. thanks...
  • Banned
    [DELETED]
  • PHP is generally used to create a static site when you want to build a site for many users & also it provides you security but in the case of html your theme can be copied easily.
    • [1] reply
    • I think it's safe to say that pure HTML (maybe with some JavaScript) will suffice for pretty much all kinds of salespages and so on ... and once you get to the point of needing PHP to make things work the way you envisioned them, you will certainly know it ...
  • I don't know why this topic seems to come up so much, but there is a lot of confusion about this subject. People don't seem to realize that 100% of all websites use HTML, no matter what is serving it from the back-end.

    PHP and HTML are not two things that can even be compared, since they are not the same category of thing. PHP wouldn't do much without HTML, since its primary purpose is usually to generate HTML. All PHP parsing happens before anything hits your browser. Browsers don't understand PHP, they only read client side code, all of which would not function without HTML, which is also totally client-side. PHP is a server-side code, HTML is a client-side code. You can't just compare these two things, because they aren't related, except for the fact that PHP can be used to generate HTML.
    • [1] reply
    • Following in the vane of this thread, I'm confused as to when I visualize my website using Firebug and it shows the html code. I can then edit the html to make it look like I desire but it doesn't, of course, save the action.

      Where do I go on my Wordpress and Theme to find the actual html code for editing? I know where the CSS files are and the code exist for Php files in my File Manger and cPanel.

      The real question making me crazy right now is where do I find the Page Setup code that establishes the parameters of my Center Page in my WP Visual Editor? I would really like to raise my h1 title up about three or four hard returns.

      I can't tell you how much time I've spent trying to find my answer and trial and error hunting around the Theme Attributes control panel.
      • [2] replies
  • Banned
    [DELETED]
    • [1] reply
    • errr...? You've got me much confused after these comments.

      For one, HTML is NOT a programming language. Not even a little bit.
      Second, PHP is for MUCH more than just retrieving data from a database. It does not even require a database to work. It just happens to have some great functions for working with databases built into the language.

      And what do you mean by PHP is used after HTML? All PHP processing happens before any HTML is ever served to the browser.
  • Banned
    [DELETED]
  • PHP is Server Side and works hand in hand with html
  • Banned
    [DELETED]
  • Banned
    [DELETED]
  • Php is dynamic and allows you to access database whereas HTML is a static which doesn't allow you to do so.You can use HTML in your PHP coding.

    So it wont really matter what you are using. You have to switch to PHP when your will require to implement complex stuff which u can do it in HTML

Next Topics on Trending Feed

  • 14

    Alright guys At the moment I am totally confused to the differences between HTML and PHP.. Does it really matter if I just create my websites in HTML format?? What are the benifits of creating a site in PHP format please?