Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Caching PHP output in static file
Old 12-08-2007, 03:05 PM Caching PHP output in static file
Moldarin's Avatar
Extreme Talker

Latest Blog Post:
Keyword Density and Title Tags
Posts: 201
Trades: 0
Hi forum,

How can I put the output of a PHP script and cache it in a static XML document? I presume I will have to use output buffering and write it to the file somehoow?
__________________
I do not share ad revenue.
Moldarin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-08-2007, 04:44 PM Re: Caching PHP output in static file
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
I presume I will have to use output buffering and write it to the file somehow?
Exactly!

Send an ob_start() at the beginning of your script, and use an ob_get_clean() to retrieve the text in a variable.

Then, it's up to you to write it in a file, or store it in a db.
If the process needs to be site-wide, take a look at the auto_prepend_file and auto_append_file php.ini directive (you can set them up on a per-host base too, via .htaccess).
When I needed this, I did the ob_start in the prepended file, and the get_clean + storage in the append.

That way, I did not need to modify the already used scripts.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-08-2007, 09:11 PM Re: Caching PHP output in static file
Moldarin's Avatar
Extreme Talker

Latest Blog Post:
Keyword Density and Title Tags
Posts: 201
Trades: 0
How would I go about specifying paths and file names for the outputted files?

Let us say I generate a lot of documents via something like WordPress. How could I get static versions of all the dynamically created pages?
__________________
I do not share ad revenue.
Moldarin is offline
Reply With Quote
View Public Profile
 
Old 12-09-2007, 02:28 AM Re: Caching PHP output in static file
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Good article here http://www.php-mysql-tutorial.com/cms-php-mysql.php.
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Caching PHP output in static file
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.57382 seconds with 12 queries