cordoprod Posted June 5, 2008 Share Posted June 5, 2008 Hi. I was just wondering of one thing. Let's say i want to add smilies. When i use the str_replace function i'll need a variable. But i want to replace the whole page.. Is that possible? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 5, 2008 Share Posted June 5, 2008 what do you mean by replace the whole page? Quote Link to comment Share on other sites More sharing options...
cordoprod Posted June 5, 2008 Author Share Posted June 5, 2008 If i have index.php And i want to replace e.g "hello" with "hi" in the whole page not just in a variable Quote Link to comment Share on other sites More sharing options...
Wolphie Posted June 5, 2008 Share Posted June 5, 2008 Unless you're getting all of your content from a database, just do a preg_replace() on that. http://uk2.php.net/manual/en/function.ob-start.php Quote Link to comment Share on other sites More sharing options...
cordoprod Posted June 5, 2008 Author Share Posted June 5, 2008 Like this? <?php function callback($buffer) { // replace all the apples with oranges return (str_replace("apples", "oranges", $buffer)); } ob_start("callback"); ?> <html> <body> <p>It's like comparing apples to oranges.</p> </body> </html> <?php ob_end_flush(); ?> Quote Link to comment Share on other sites More sharing options...
Wolphie Posted June 5, 2008 Share Posted June 5, 2008 Precisely. Quote Link to comment Share on other sites More sharing options...
cordoprod Posted June 5, 2008 Author Share Posted June 5, 2008 Precisely. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.