Jump to content

Echo into a variable?


Recommended Posts

Is there anyway that I can take the output of echo and put it in a string variable?

 

The reason I ask is because I'm using some stupid pre-built web program and it will echo out the variable value just fine.  But internally to get this variable there are some 20-something different functions that return this value up a hierarchy.  And whenever I pass this variable to anything to compare it to some string, it can't do crap with it.  I really don't have the time to search through all these nested calls to see how the programmer formatted it. 

Link to comment
https://forums.phpfreaks.com/topic/108843-echo-into-a-variable/
Share on other sites

I would take a look at this:

 

http://us.php.net/ob_start

 

From the documentation:

 

<?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();

?>

 

The above example will output:

 

<html>

<body>

<p>It's like comparing oranges to oranges.</p>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/108843-echo-into-a-variable/#findComment-558324
Share on other sites

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.