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?
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.
"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-- Douglas Adams
Have you minified
your CSS/JS lately?
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.
<?php ...codehere... ?>
Last edited by damndaewoo; 05-21-2012 at 12:22 AM.
Reason: because ... I forget...
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.
Yes W3schools is very good tutorial site. You can easily find the solution of your every question related to html and php.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread