@ (at sign) in Drupal strings

2019-02-27 10:09发布

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.

标签: drupal
1条回答
唯我独甜
2楼-- · 2019-02-27 10:42

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.

查看更多
登录 后发表回答