Page 1 of 1
Embedding PHP code/file in HTML file
Posted: Thu Feb 01, 2007 4:41 am
by dagadakrishna
hi can anyone help me how to embedd PHP file/code in HTML file
suppose i have HTML file Like this
<html>
<head></head>
<body>
WELCOME
</body>
</html>
here suppose if i want to put PHP code how to do.
I have written like this in my "Welcome.html"
<html>
<head></head>
<body>
WELCOME
<h1>
<?php echo "I LOVE PHP!"; ?>
</h1>
</body>
</html>
But its not working.
is it the correct way of writing
And another one is if i want to include PHP file in my HTML file means whats the procedure, can any one suggest me
Byeeeeeeee
Posted: Thu Feb 01, 2007 6:14 am
by matthijs
Code: Select all
<html>
<head></head>
<body>
WELCOME
<h1>
<?php echo "I LOVE PHP!"; ?>
</h1>
</body>
</html>
Did you save the page as welcome.
php? The extension is important.
Your code is ok.
Posted: Thu Feb 01, 2007 6:18 am
by dagadakrishna
Means with .html extension is it not possible?
.php extension means it will become PHP file na,i want it in HTML file only is it not possible?
Posted: Thu Feb 01, 2007 7:46 am
by Dr Evil
It has to be *.php as this tells the server what the file contains and makes the server parse it.
A *.php file can contain only html if you wish.
Make sure you have a server running on your testing machine too, or you want get proper output.
(you could configure your server to parse *.html too, but I strongly sugest you don't).
Posted: Thu Feb 01, 2007 8:33 am
by superdezign
If you are at all set on using html files however, you would put your php code into separate *.php files and then include them into your html
Posted: Thu Feb 01, 2007 10:22 pm
by dagadakrishna
hi u gave me a suggestion of placing <!--#include file="*.php"--> this iin HTML code ,but where to put this code
i tried like this its not working
my Welcome.html file
<html>
<head>
#include file="data.php"
<title>PHP Test</title>
</head>
<body>
</body>
</html>
Where to put that line
Posted: Thu Feb 01, 2007 10:35 pm
by superdezign
firstly, the <!-- --> is part of the syntax
Secondly, you can put it whereever. If it outputs anything you probably want it in the body. Otherwise, who cares where you put it? :-p
Posted: Thu Feb 01, 2007 11:15 pm
by gavin1996
Guy,you should using javascript or iframe
<script src="../temp.php"></script>
<iframe src=''></iframe>
Posted: Thu Feb 01, 2007 11:25 pm
by dagadakrishna
ya what u told is correct its working fine
Thanks for ur help
Posted: Thu Feb 01, 2007 11:30 pm
by dagadakrishna
if u put <!--#include file="text_file_hit_counter.php"--> like this then it will become comment na how it will become sytax
Posted: Fri Feb 02, 2007 9:15 am
by feyd
LAST WARNING before punishment is handed out dagadakrishna.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.