Gossamer Forum
Home : General : Perl Programming :

build static page from *.php

Quote Reply
build static page from *.php
Hi,

I want to build a static html page from a dynamic one, how Links SQL does with its dynamic cgi pages.
I use a php file. What do I have to do?

Sven
Quote Reply
Re: [SvenL] build static page from *.php In reply to
Do you mean actually build or just load?
Quote Reply
Re: [PaulW] build static page from *.php In reply to
after pressing a button or opening build.php the page has to create build.html
is it fopen() ???
Quote Reply
Re: [SvenL] build static page from *.php In reply to
Try

Code:
$fp = fopen ("build.html", "w");
fputs($fp,$out);
fclose($fp);
where $out is the content of your file.


Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [SvenL] build static page from *.php In reply to
http://www.php.net/...n/function.fopen.php
http://www.php.net/.../function.fclose.php
http://www.php.net/...n/function.fputs.php

Last edited by:

PaulW: Dec 17, 2001, 3:14 AM
Quote Reply
Re: [yogi] build static page from *.php In reply to

Code
<?php
$out = ("
<html>
<head>
<title>Title</title>
</head>
<body>
<?php
print (\"Hello Web\");
?>
</body>
</html>
");
$fp = fopen ("build.htm", "w");
fputs($fp,$out);
fclose($fp);
?>



If I use this code, the php code will not be executed.
Quote Reply
Re: [SvenL] build static page from *.php In reply to
I thought your output page was static....

If you want to output php pages, you should rename build.htm to build.php (or something like that, depending on the configuration of your webserver).


Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] build static page from *.php In reply to
Yes,
I have 2 files.
FILEA.PHP gets its infos from a database. Now this file shall build FILEB.HTM.
I want this, because the datas do not change very often and a connection to the
database takes too much CPU power.

It shall work like GTSQL. There you have a CGI file which builds static HTML files.
Quote Reply
Re: [SvenL] build static page from *.php In reply to
You need to build the output in FILEA.PHP then print it to the HTM file.

Should work fine.
Quote Reply
Re: [PaulW] build static page from *.php In reply to
Could you please tell me how?
Quote Reply
Re: [SvenL] build static page from *.php In reply to
I think I told you....

i.e. put your php code in build.php, and output build.htm (but build.htm should NOT contain any php code, otherwise it won't work).


Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] build static page from *.php In reply to
what do you mean by output build.htm?

With your help, build.php creates build.htm. The content of build.htm is $out.

Quote Reply
Re: [SvenL] build static page from *.php In reply to
OK.

build.php saves a file called build.htm to disk. That's what you want, isn't it? Just make sure that $out doesn't contain any php commands (the example you gave does contain php commands, i.e. it won't work, because your webserver probably doesn't parse files with extension .htm).

Clear? Or do I not get the point?


Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] build static page from *.php In reply to
Yes, I want build.php save a file called build.htm to disk. But what do I have to do that
$out is parsed first and then build to a htm file?




Quote Reply
Re: [SvenL] build static page from *.php In reply to
Now I get your point...

You don't want to parse $out, you want to build it up to contain all the static html. For example:

Code:
$out .= "<html><body>";
$out .= result_of_some_query($arguments);
$out .= "</html>";
where the function result_of_some_query($arguments) returns html code.

This is just a very simple example. You should probably read the documentation (links provided by PaulW above).


Ivan
-----
Iyengar Yoga Resources / GT Plugins