writing new html page through php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sksangtani
Forum Newbie
Posts: 2
Joined: Thu Nov 19, 2009 5:32 am

writing new html page through php

Post 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.
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: writing new html page through php

Post 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 :P
User avatar
vargadanis
Forum Contributor
Posts: 158
Joined: Sun Jun 01, 2008 3:48 am
Contact:

Re: writing new html page through php

Post 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.
Post Reply