@ (at sign) in Drupal strings

2019-02-27 10:05发布

问题:

In another question, someone posted this code in an answer to my question.

drupal_set_message(
  t('Some Message @title'), array('@title' => $form_state['values']['title']))
);

It looks to me that the "@title" is substituted with $form_state['values']['title'].

What is this called and what are the advantages and disadvantage of it?

From a quick look, I see that @ is used for error suppression, but this is reported in a PHP 4.3 book I have, rather than PHP 5.

回答1:

In Drupal, an @ sign in front of a placeholder is used to signal to Drupal's string parser to run the string attached to the placeholder through check_plain().

More info about string placeholders can be found on the t() API page.



标签: drupal