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?
Printable View
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?
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?
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
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.HTML Code:<?php ...codehere... ?>
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.
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
Yes W3schools is very good tutorial site. You can easily find the solution of your every question related to html and php.