Saturday, 27 June 2015

Debug PHP using XdeBug in Browser console...nice

 Parses PHP debugging log messages via JSON into browser console.
<?php
/**
 * Send debug code to the Javascript console
 */
function debug_to_console($data) {
    if(is_array($data) || is_object($data))
    {
        echo("<script>console.log('PHP: ".json_encode($data)."');</script>");
    } else {
        echo("<script>console.log('PHP: ".$data."');</script>");
    }
}
?> 

0 comments:

Post a Comment