How to print variable/debug data from your extension.php?
(Update) As of v4.7.0, the approaches below still work, but there's a better way to write to the log file using a PSR-3 logger, e.g.:

Civi::log()-&gt;info('Hello, log!');
Civi::log()-&gt;error('I'm sorry, {name}. I'm afraid I can't do that.', array(
  'name' =&gt; 'Stanley Kubrick',
));


See also:
https://civicrm.org/blog/totten/the-static-is-dead-long-live-the-static



To write out to CiviCRM's ConfigAndLog folder, one can use either:

CRM_Core_Error::debug_log_message('hello log');
CRM_Core_Error::debug_var('name', $var);


There's also an experimental PSR-3 logger (CRM_Utils_SystemLogger) which writes out to the database (table civicrm_system_log), e.g.

$log = new CRM_Utils_SystemLogger();
$log-&gt;info("hello log");
$log-&gt;error("I'm sorry, {name}. I'm afraid I can't do that.", array(
  'name' =&gt; 'Stanley Kubrick',
));


If the debug statement is temporary (won't be committed/redistributed), then you can usually use CMS-specific functions (like Drupal devel's dpm() or Joomla's JLog).