Page 1 of 1
writing new html page through php
Posted: Thu Nov 19, 2009 5:37 am
by sksangtani
I want to write a new html page through php script. It is something like a redirection but not to a static page but to a page which is written through php.
Re: writing new html page through php
Posted: Thu Nov 19, 2009 7:50 am
by iankent
Makes no sense, could you explain in more detail?
Do you want to redirect the user, or output HTML? If you want to output HTML from a PHP script there's three ways:
1. Just make it part of the page, e.g.
Code: Select all
<html><head><title>blah</title</head><body>
<? your php here ?>
<b>some more html</b>
<? more of your php here ?>
</body></html>
2. use echo, printf or a long list of other functions to output HTML, e.g.
Code: Select all
echo '<html><head><title>Hello</title></head>';
$i = 1 + 5;
// more php here
echo 'more HTML here';
3. I got distracted and can't remember - will come back to this one

Re: writing new html page through php
Posted: Thu Nov 19, 2009 7:54 am
by vargadanis
Ahm I am not sure if I understand your problem but I guess this is what you want.
You have some PHP files that display some HTML stuff and a 3rd one that will controll which which php files (that contain HTML) to display, right?
In that case I'd just include them as fallows:
controller.php
Code: Select all
/* some code */
require_once 'php/file/to/display.php';
This will execute the PHP file and show the HTML. You might not even want to put any PHP tags in it, only pure HTML.