SyntaxError:格式错误的十六进制字符转义序列

I am trying to get current working directory in PHP like below

$path = realpath(dirname(__FILE__));
debug_to_console ('path'.$path);

and function for log is like below

function debug_to_console( $data ) {
    $output = $data;
    if ( is_array( $output ) )
        $output = implode( ',', $output);

    echo "<script>console.log( 'Debug Objects: " . $output . "' );</script>";
}

its giving me error in console like below

SyntaxError: malformed hexadecimal character escape sequence

can anyone please correct me whats the wrong in it? Thanks