Passing an object to hook_menu I am trying to pass an object from a function to the menu item (Not sure if drupal allows that), I get the following error 'Recoverable fatal error:Object of class stdClass could not be converted to string'. The following is my function and the menu item. 

function add2basket_link($val) {
  $build = array();
  $build['add2basket_link'] = array(
  '#type' =&gt; 'link',
  '#title' =&gt; t('Bucket'),
   '#href' =&gt; 'basket/add/'.$val. '/nojs/',
  );
  return render($build);
  }

 function bucket_menu(){
   $items['basket/add/%'] = array(
   'page callback' =&gt; 'data_add2basket',
   'page arguments' =&gt; array(2),
   'access arguments' =&gt; array('use basket'),
   'type' =&gt; MENU_CALLBACK,
   'file' =&gt; 'data.inc',
   );
  return $items;
 }

The error points to the line of " '#href' =&gt; 'basket/add/'.$val. '/nojs/', " from the add2basket_link function
You could concat only string with strings, It's php :)
What you can do is to use hook_load() something like this:

function add2basket_link($val) {
  $build = array();
  $build['add2basket_link'] = array(
    '#type' =&gt; 'link',
    '#title' =&gt; t('Bucket'),
    '#href' =&gt; 'basket/add/'. $val-&gt;lid . '/nojs/',
  );
  return render($build);
}

/**
 * Implements hook_menu().
 */
function bucket_menu(){
  $items['basket/add/%bucket_link_id'] = array(
    'page callback' =&gt; 'data_add2basket',
    'page arguments' =&gt; array(2),
    'access arguments' =&gt; array('use basket'),
    'type' =&gt; MENU_CALLBACK,
    'file' =&gt; 'data.inc',
  );
  return $items;
}

/**
 * Implements hook_load().
 */
function bucket_link_id_load($lid) {
  // 'bucket_link_id' is from hook_menu() from $items['basket/add/%bucket_link_id'].
  // lid is id that was passed from add2basket_link() to the #href.
  // link_load() is function to load your object.
  return link_load($lid);
}