JSFiddle - React, Tailwind, and code Playground

by luizz

HTML

<pre>

function console() {
//
//    if ($_SERVER["REMOTE_ADDR"] != "187.5.68.84" || $_SERVER["REMOTE_ADDR"] != "127.0.0.1") //IP YOUZOOM
//        return;

    static $output = '', $doc_root;
    
    $args = func_get_args();
    
    if (!empty($args) && $args[0] === 'print') {
        
        $_output = $output;
        $output = '';
        
        $non_displayables = array();
				
		$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S';	// 00-08, 11, 12, 14-31, 127

		do
		{
			$_output = preg_replace($non_displayables, '', $_output, -1, $count);
		}
		while ($count);

        $_output = str_replace("\n", "", $_output);
        return "<script charset=\"UTF-8\" src=\"data:text/javascript;base64," . base64_encode($_output) . "\"></script>";
    }
    // do not repeat the obvious (matter of taste)
    if (!isset($doc_root)) {
        $doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
    }

    $backtrace = debug_backtrace();

    // you may want not to htmlspecialchars here
    $line = htmlspecialchars($backtrace[0]['line']);
    $file = htmlspecialchars(str_replace(array('\\', $doc_root), array('/', ''), $backtrace[0]['file']));
    $class = !empty($backtrace[1]['class']) ? htmlspecialchars($backtrace[1]['class']) . '::' : '';
    $function = !empty($backtrace[1]['function']) ? htmlspecialchars($backtrace[1]['function']) . '() ' : '';

    $output .= "console.group(\"$file #$line => '%s'\",\"$class$function\");";

    @ob_start();
    foreach ($args as $arg) {
        var_dump($arg);
    }

    $output .= "console.log(\"%s\",\"" . addslashes(ob_get_contents()) . "\");\n";
    @ob_end_clean();

    $output .= "console.groupEnd();";
};
  
  console($var); //Usando 
  
  
  // incluir no inferior's
  
  echo console('print');
</pre>
    
</script>