Just a simple question that everyone who works with php probally knows.
Can i put html code into a php file ? And if i do will it work ?
Sure. If you just rename your .html to .php, and if your server supports php (of course), it'll display without any problem.
echo "<strong>Html code</strong>";
| Kurosaki-Ichigo wrote: |
Just a simple question that everyone who works with php probally knows.
Can i put html code into a php file ? And if i do will it work ? |
| Code: |
<?php
// Your phpcode
?>
<b>This is normal htmlcode</b>
<?php
// Some other phpcode
?> |
With Stubru Freak's solution the htmlcode will be shown on the page. Formatting tags or link- and imagetags won't work. It's just text.
Ofcourse the file must be .php
| TomS wrote: |
| Kurosaki-Ichigo wrote: | Just a simple question that everyone who works with php probally knows.
Can i put html code into a php file ? And if i do will it work ? |
| Code: | <?php
// Your phpcode
?>
<b>This is normal htmlcode</b>
<?php
// Some other phpcode
?> |
With Stubru Freak's solution the htmlcode will be shown on the page. Formatting tags or link- and imagetags won't work. It's just text.
Ofcourse the file must be .php |
Not true, your and my solution have exactly the same result.
Look. I have a script and it has a Download.php . Now i want to put a google adsense script for example inside it. How do i do this ?
As the French say, c'est trés facile. Or as the English say, it is very easy.
When you have your php document, it doesn't even have to have PHP in it and it still works.
You don't want to have everything all done in PHP when you don't need to.
An example of how to have two in one is this.
This page is called download.php
| Code: |
<HTML>
<HEAD>
<title>My Download Site</title>
</HEAD>
<BODY>
<img src="header.jpg">
<h1><font face="Arial">Welcome to the site of downloads</font></h1>
<h3><i>The place where the fun doesn't stop until our bandwidth does.</i></h3>
INSERT YOUR GOOGLE SCRIPT HERE
<?php
$var = $_GET['download'];
echo '
<script language='javascript'>
download(' . $var . ');
</script>
';
?>
</BODY>
</HTML>
|
So as you can see anything outside the <?php tags is just printed like normal HTML code, but when you want to add PHP power, make sure the filename is *.php and go for it.
*** NOTE: This is made up code.
Last edited by X3 Talk on Wed Oct 18, 2006 5:33 am; edited 1 time in total
yea html code can go into php
Thanks. One more question, What would happen if the html went inside the PHP codes ?
@Stubru Freak: Ähm. Jap. But why the <strong> then?
| TomS wrote: |
| @Stubru Freak: Ähm. Jap. But why the <strong> then? |
To show the text bold.
Yes you can like,
<?php
echo 'hello world my new site' //and if you want a line below it you use <br> so: instead of the echo <==
you use <?php
echo 'hello world <br> My new site';
?>