www.webdeveloper.com
Results 1 to 6 of 6

Thread: how to embed php into html

Hybrid View

  1. #1
    Join Date
    Apr 2012
    Posts
    16

    how to embed php into html

    Hi everyone, I want to know the procedure by which we can embed php into html. what should be the file type. What is difference between .php and .phtml files. What file type should I use?

  2. #2
    Join Date
    May 2012
    Posts
    37
    You don't really embed php into HTML... php is a server-side language - meaning it doesn't get interpreted by your browser the way css/javascript/html does. Instead it's executed on the web server - you'll never see php code.

    The benefit of this is that you can do all kinds of logic and manipulation of data, and then send some formatted HTML to the browser for display the results.

    .phtml and .php are the same thing though you really don't see .phtml too much anymore. On the server side, you can configure the extension to use for php.

    That help?
    "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools."
    -- Douglas Adams

    http://www.chaoscontrol.org
    Have you minified your CSS/JS lately?

  3. #3
    Join Date
    May 2011
    Posts
    52
    if you want to have lines of php in your webpages that do specific things when the page is loaded by the server before sending to the client then you need to have the .php file extension (.phtml is probably safe to say deprecated now) and you need to wrap your code inside of the below tags
    HTML Code:
    <?php ...codehere... ?>
    teh important part is to make sure you have the <?php at the start and the ?> at the end otherwise the server wont recognise it and you will serve your code as part of the webpage. hope that helps.
    Last edited by damndaewoo; 05-20-2012 at 11:22 PM. Reason: because ... I forget...

  4. #4
    Join Date
    Apr 2012
    Location
    Denver, Colorado, USA
    Posts
    22
    Use php tag<?php ?> add your code to this file and save this file as.php after doing this task you can easily embed this file to html.

  5. #5
    Join Date
    May 2012
    Location
    BATH UK
    Posts
    7
    Obviously make sure your web server supports php, but most usually do.

    A good resource for beginner information is the w3schools website found at www.w3schools.com/php/

    This should let you know everything you need.

    Andy Grant
    www.oodeveloper.com

  6. #6
    Join Date
    Apr 2012
    Location
    Denver, Colorado, USA
    Posts
    22
    Yes W3schools is very good tutorial site. You can easily find the solution of your every question related to html and php.

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles