How to display a variable in callback hook_menu?
Based on your code, it should be written as

$output =  array(
  'first_para' =&gt; array(
    '#type' =&gt; 'markup',
    '#markup' =&gt; '&lt;p&gt;Test&lt;/p&gt; ' . $user_agent,
  ),
);


rather than

$output =  array(
  'first_para' =&gt; array(
    '#type' =&gt; 'markup',
    '#markup' =&gt; '&lt;p&gt;Test&lt;/p&gt; ' $user_agent,
  ),
);


You need the period to concatenate the your string and variable.

Edited - Full working module

/**
 * Implements hook_menu().
 */
function testing_menu() {
  $items = array();
  $items['custom_module'] = array(
    'title' =&gt; 'My Custom Module',
    'description' =&gt; t('Best Custom Module'),
    'page callback' =&gt; 'testing_back',
    'access arguments' =&gt; array('administer site configuration'),
  );
  return $items;
}

function testing_back(){  
  $user_agent = $_SERVER['HTTP_USER_AGENT'];
  $output =  array(
    'first_para' =&gt; array(
      '#type' =&gt; 'markup',
      '#markup' =&gt; '&lt;p&gt;Test&lt;/p&gt; ' . $user_agent,
    ),
  );
  return $output;
}