View Full Version : Php In Html
wolflacrosse
12-16-03, 10:11 PM
Hey Guys,
I want to make my .html open a .php code in it or .php open a .html code. I have easyphp, but I do not know the command line in the html or php to get it to open the php or html within the page.
Thx
Wolf
wolflacrosse
12-16-03, 10:13 PM
What cna I use to read the php/html. I know html well but i cant get the 2 to work together
Im not really understanding what your saying but there are a few things...
1) .HTML files cannot read PHP code.
2) .PHP can read HTML code.
3) You can read another page using an IFRAME (only works on certain browsers)
<iframe src="PAGE YOU WANT TO SEE.HTML">Your Browser Doesnt Support IFrames</iframe>
I dont get what you mean by:What can I use to read the php/html. I know html well but i cant get the 2 to work together
Hope that helps ;)
BoneChrif
12-25-03, 06:34 PM
This is how to put php code in html:
<html><head><title>PHP in HTML</title>
<body>
<?php
//php code
?>
</body
</head>
</html>
I hope I helped
I know berely any PHP but I still know a little
jayhawk
12-25-03, 07:02 PM
BoneChrif and Dale are correct.
In addition to their posts you can use include or require statements to bring another page in.
For example,
In PHP:
<?php
require("header.php");
?>
In HTML:
<!--#INCLUDE FILE="filename.html"-->
Please clarify your question if our posts do not make sense.
NeverMind
12-26-03, 03:46 AM
This is how to put php code in html:
<html><head><title>PHP in HTML</title>
<body>
<?php
//php code
?>
</body
</head>
</html>
if you used this solution you need to make the file php not html or the html file will show your php code ... once you want to have some php in html open php tags ' <?php ' and after you finish close it with ' ?> ' ... you can have as many blocks of php in your html as you want ..
and as jayhawk said use:
include_once('page.php');
//or
require_once('file.html');
you can use these functions to include any file type ...
<!--#INCLUDE FILE="filename.html"--> are used in SHTML files .. so you need to rename the extension of your html to SHTML if you want to use virtual includes ...
but though php wont be excuted if the file extension was not php ...
The format is as follows. This is the one I use most frequently...
( put the following in a .php file )
<?php
// php code here
// at this area,
// you might want to do the variables
// and mathematics operation
// and do functions here
// in this one,
// we'll create a variable
// $hello with a value of 1
$hello = Hello there how are you?;
?>
// html code starts below
<html>
<head>
<title>Hello there script</title>
</head>
<body>
<?php
// php start tag <?php
echo "<p>$hello</p>";
// php end tag ?>
?>
</body>
</html>
// end code
What would basically happen is that the php interpreter would look thru the script and when it sees the php start and end tags, it would read as PHP. When it sees the <html> tags, it would read as plain old HTML. In between, HTML, if the interpreter sees a php tag, it would do interpret the stuff inside as PHP and then subsequently echo/print the result of the PHP code, or a return value...
You really should get a book on PHP seeing that you are so confused. I don't think you really actually know what you are talking about in the first place!!
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.