Wallace Maxters Posted on Feb 27, 2021 • Edited on Feb 27, 2021 • Originally published at wallacemaxters.com.br Simply way to write PHP output in Javascript console.log #javascript #php You can simply combine the printf and json_encode function to make this. function console_log($data) { printf('<script>console.log(%s);</script>', json_encode($data)); } console_log(['name' => 'Wallace Maxters']); Enter fullscreen mode Exit fullscreen mode Output: Top comments (0) Subscribe Submit Preview Dismiss Code of Conduct • Report abuse
Top comments (0)