How to display a variable in callback hook_menu? I'm creating a page with Hook_menu and I would like to display the user agent that page. This is my code to generate my page.

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

function custom_module_back(){  
        $output =  array(
            'first_para' =&gt; array(
                '#type' =&gt; 'markup',
                '#markup' =&gt; '&lt;p&gt;Test&lt;/p&gt; '  
            ),
        );
        return $output;
    }


I try to set a variable like this $user_agent = $_SERVER['HTTP_USER_AGENT']; and then call it after the p tag.

Like this 

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


And this did not work.

How can I display a variable into a callback ?
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;
}