Jump to content

checking all the page output


asmith

Recommended Posts

Hey guys

 

Is there any function, or any way I could filter my output without having to do it variable by variable?

 

for example  : 

 

str_replace("the site","<b>the site</b>", WHOLE_PAGE);

 

so that it searches for "the site" in my entire page output and make the site bold...

 

any idea?

 

 

Link to comment
https://forums.phpfreaks.com/topic/125772-checking-all-the-page-output/
Share on other sites

How you do it with str_replace?

 

I have a heavy large pages which a lot of variables are being "echo"ed. 

If i want to use str_replace, I have to search entire files for variables and put them in str_replace function.

 

the question is , How to do all without having to str_replace them one by one. 

You could use output buffering to capture the entire page into a variable. eg;

 

<?php
  ob_start();
?>
<html>
  <head>
    <title>foo</title>
  </head>
  <body>
    <p>this is a paragraph about the site</p>
    <p>I like to talk about the site allot</p>
  </body>
</html>
<?php
  $out = ob_get_contents();
  $out = str_replace("the site","<b>the site</b>", $out);
  ob_end_clean();
  echo $out;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.