php question about embedding php?

ok, i know how to embed html into a php page but how to i embed another php page into it without copying the main source code? can anybody tell me source code? kinda like iframes for php? maybe i could try changing to html in the coding, then using an iframe to embed the other php page? thanks
 
Nah, Jason has the right idea. Here's an example with both:
<?php
echo "<html>
<body>
<p> This is HTML in PHP file!</p>";
include("./somepage.php");
?>

inlclude("file_source"); is the code you use to add all the script inside a different PHP file to the current one.
the includeis like a <script type='text/javascript' src='file_source'> which brings JAVASCRIPT from a different .js file to the current one.

Best answers always appreciated.
 
PHP pages are not really PHP pages they are PHP + HTML Pages. If you wanted the title of a page to be a variable you could do:

<?php
$helloworld = "23";
?>

<html>
<head>
<title>
<?php
echo $helloworld;
?>
</title>
</head>
<body>
</body>
</html>

Just use the php tags (<?php and ?>) to open and close sections of php code and the rest is pure html.

to embed a different file use either:

include("myfile.php");

or

require("myfile.php")

only difference is in how they handle errors.
 
PHP pages are not really PHP pages they are PHP + HTML Pages. If you wanted the title of a page to be a variable you could do:

<?php
$helloworld = "23";
?>

<html>
<head>
<title>
<?php
echo $helloworld;
?>
</title>
</head>
<body>
</body>
</html>

Just use the php tags (<?php and ?>) to open and close sections of php code and the rest is pure html.

to embed a different file use either:

include("myfile.php");

or

require("myfile.php")

only difference is in how they handle errors.
 
Back
Top