HN user

btraut

3 karma
Posts2
Comments2
View on HN

The other <pre> and print_r()-based solutions don't work quite as well when you're writing an AJAX-based app. I use error_log for everything:

  // PHP error_log() wrapper
  function el($var, $die = true) {
     error_log(var_export($var, true));
  
     if ($die) {
        die();
     }
  }
Also, Paul Irish's Javascript log() function is amazing. It can be found in boiler plate, but here's the gist:
  // Javascript console.log() wrapper
  window.log = function() {
     log.history = log.history || [];
     log.history.push(arguments);
  
     if (this.console) {
        console.log(Array.prototype.slice.call(arguments));
     }
  };