PHP - 加粗 t 内的某些文本

标签 php html css drupal

$need_it_sooner = l(
    t('Need it sooner? Click here'), 
    'need-it-sooner', array(
    'attributes' => array(
            'class' => array('float-right', 'button', 'button-red'),
            'style' => 'float:right;',
        ))
    );

这是我的代码,我想显示它

Need it sooner? Click here.

我能否在 t() 中轻松设置文本样式,还是我必须编写另一个大块来完成此操作?

最佳答案

在 Drupal 7 中,函数 l 将选项数组作为第三个参数。如果您向它传递选项 'html' => TRUE,它可以接受 HTML。 您也可以通过函数 t 传递 HTML。所以你可以尝试这样做:

$need_it_sooner = l(
    t('<strong>Need it sooner?</strong> Click here'), 
    'need-it-sooner', array(
    'attributes' => array(
            'class' => array('float-right', 'button', 'button-red'),
            'style' => 'float:right;',
        ),
    'html' => TRUE)
    );

关于PHP - 加粗 t 内的某些文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50237344/

相关文章:

php - 如何将此查询转换为 Laravel 查询生成器?

php - 任何人都知道文件大小作为 PHP 中的值对象的良好实现?

php - 从 JSON API 获取数据到 JS 或 jquery 变量

css - 由于某些未知原因,用 CSS 制作的类不会影响 HTML

html - FlexLayout Angular 并在开始和结束时在一行中对齐元素

php - 子查询顺序

javascript - 使用位于动画背景上方的 Bootstrap 3 获取网页内容

javascript - 背景的流体/连续图像滚动

html - 标题前的 CSS 形状(正方形)

javascript - 避免在手机中加载图像