For example:

watchdog('alerts', 'Message for %user was sent.', array('%user' => $user));


drupal_set_message(t('options: @options', array('@options' => $form_state['values'])));

Is there any difference?

  • This question is, for sure, incorrectly marked as a duplicate. That question (of which this one is NOT a duplicate) is about "Replacement tokens" in the "Message" module (= some technique used in combination with the Rules module), and has nothing to do with what the question is here is about. – Pierre.Vriens Aug 8 '17 at 13:17

Have a look into the function definition of the format_string() function which is used by the t() function:

Each type of placeholder has a way in which this function intrepretes it:

@variable: Escaped to HTML using check_plain(). Use this as the default choice for anything displayed on a page on the site.
%variable: Escaped to HTML and formatted using drupal_placeholder(), which makes it display as <em>emphasized</em> text.
!variable: Inserted as is, with no sanitization or formatting. Only use this for text that has already been prepared for HTML display (for example, user-supplied text that has already been run through check_plain() previously, or is expected to contain some limited HTML tags and has already been run through filter_xss() previously).
  • And even though there is no t() function in the first example, the message should use placeholders because it can be translated at a later point. – Kari Kääriäinen Oct 4 '13 at 18:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.