Skip to content
Advertisement

get return from echo

I’m working with some functions that echo output. But I need their return so I can use them in PHP.

This works (seemingly without a hitch) but I wonder, is there a better way?

JavaScript

Example:

JavaScript

Advertisement

Answer

no, the only way i can think of to “catch” echo-statements it to use output-buffering like you already do. i’m using a very similar function in my code:

JavaScript

it’s just 2 lines shorter and does exactly the same.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement