Store source code of a page

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
vadim77
Forum Newbie
Posts: 1
Joined: Sat Mar 20, 2004 8:39 am
Location: Germany

Store source code of a page

Post by vadim77 »

Hi, i have written a php script which creates a lot of text (javascript) from values of a database.This values do not change often, so there is no need to generate them each time the page is loading.

Basically i need something, what would call the page (which generates the javascript code) and store it in a separate file. I guess the first step is to make a long array out of the source code of the parsed page. Anyone has an idia? please help... if i use fopen it will not parse the page

Thanx in advance
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Start an output buffer, [php_man]ob_start()[/php_man], include the file that creates the js, get the output using [php_man]ob_get_contents()[/php_man] save that output to a file ([php_man]file_put_contents()[/php_man]) and clean up with [php_man]ob_end_clean()[/php_man]. Call as needed. You could even cron it. Think that will work?
Post Reply