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?
"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools."
-- Douglas Adams
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...
Bookmarks