Created
January 31, 2012 17:15
-
-
Save nfreear/1711664 to your computer and use it in GitHub Desktop.
Output a PHP string or expression as a HTTP header / Drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/**If a 'debug' parameter is set, output a PHP string or expression, probably as a HTTP header. | |
* | |
* Inspired by OUVLE ouauth module, and FirePHP. | |
* | |
* @param mixed $exp A PHP string or expression. | |
* @copyright 2012-01-31 N.D.Freear. | |
*/ | |
function _MY_DRUPAL_MODULE_debug($exp) { | |
// For Drupal, try variable_get(). | |
if ((isset($_GET['debug']) && $_GET['debug']) || variable_get('debug', NULL)) { | |
static $count = 0; | |
static $where; | |
// $where could be based on __FUNCTION__ or debug_backtrace(). | |
if(!$where)$where = str_replace(array('_','.'), '-', basename(__FILE__)); | |
@header("X-D-$where-$count: ".json_encode($exp)); | |
$count++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment