How to get output of a php function into a variable
It's pretty simple, and it can be very helpfull when for some reason you need to do a conditional display on an output from a function, but for legacy/compatibility reasons you can't modify that function.
- <?php
- ob_start();
- echo 'I like cookies';
- $myStr = ob_get_contents();
- ob_end_clean();
- ?>
Technology:
Add new comment