page_example_baz

Definition

page_example_baz($alice, $bob)
docs/docs/developer/examples/page_example.module, line 115

Description

A more complex page callback that takes arguments.

The arguments are passed in from the page URL. The in our hook_menu implementation we instructed the menu system to extract the last two parameters of the path and pass them to this function as arguments.

Code

<?php
function page_example_baz($alice, $bob) {
  // Make sure you don't trust the URL to be safe! Always check for exploits.
  if (!is_numeric($alice) || !is_numeric($bob)) {
    // We will just show a standard "access denied" page in this case.
    return drupal_access_denied();
  }

  $list[] = t("Alice's number was @number.", array('@number' => $alice));
  $list[] = t("Bob's number was @number.", array('@number' => $bob));
  $list[] = t('The total was @number.', array('@number' => $alice + $bob));

  return theme('item_list', $list);
}
?>