faqts : Computers : Programming : Languages : PHP : Not Quite PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

How can I add "preprocessor" to PHP, e.g. replace all "--" with "−" before PHP starts parsing?

Mar 28th, 2008 17:54
ha mo, Michael Felt, Sergey Igitov, http://nl3.php.net/manual/en/function.ob-start.php


I may not really understand your question. If it was me I would be
stating it more like:
How do I get PHP to "preprocess" it's output before sending it to the
client.
If this is correct I suggest you look here for the bits you need.
Basically what you want to do is save your output in an internal buffer,
retrieve that into a string, remove the original buffer, and output the
"post-processed" buffer.
That would look something like:
ob_start();
// create output
$buf = ob_get_contents();
// post-processing time ...
ob_end_clean();
ob_start();
print $post_buf; // simplified idea
ob_end_flush();
Real documentation: http://nl3.php.net/manual/en/function.ob-start.php
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com