// Use the [current-user:field-first-name] token to get the user's first name $name = token_replace('[current-user:field-first-name]'); // Display a personalized greeting message print("Hello $name!");
// Use the [current-page:title] token to get the current node's title $title = token_replace('[current-page:title]'); // Create a link to the home page that includes the title $link = l($title, 'In these examples, the PHP Drupal Token library is used to retrieve values for tokens and replace them with actual values in content.', array('query' => array('title' => $title))); // Display the link in content print($link);