【问题标题】:Capitalizing text into a website title将文本大写到网站标题中
【发布时间】:2013-04-01 00:21:20
【问题描述】:

我有一个来自未大写的 sql 数据库的文本。

在我的 HTML 中,我通常应用 CSS text-transform 来大写文本,但现在我遇到了一个问题:

我希望此文本成为我网站标题的一部分。但是,我无法在标题中设置样式。

如何设置文本样式,然后在 PHP 上抓取它,然后将其插入到我的标题中?

这是我试过的,但没有奏效:

<title>Shop - <p style="text-transform:capitalize;"><?php echo $row2['name'];?></p></title>

谢谢!

【问题讨论】:

    标签: php html styles title capitalize


    【解决方案1】:

    PHP 有几个函数可以将文本大写:

    ucwords($text)
    

    http://php.net/manual/en/function.ucwords.php

    strtoupper($text)
    

    http://www.php.net/manual/en/function.strtoupper.php

    【讨论】:

      【解决方案2】:

      你可以在 php 中使用这个函数来回显你的大写文本: http://php.net/manual/en/function.strtoupper.php
      http://php.net/manual/en/function.ucfirst.php

      【讨论】:

        【解决方案3】:

        你需要使用PHP转换。

        <?php echo ucfirst($row2['name']); ?>
        

        你可以使用很多函数,ucfirst、ucwords、strtoupper。

        作为W3C notes,您应该只使用文本,并且最大长度为 64 个字符:

        标题不是文档文本的一部分,而是整个文档的属性。它可能不包含锚点、段落标记或突出显示。

        【讨论】:

          【解决方案4】:

          你可以使用

          ucfirst($row2['name']) 
          

          【讨论】:

            【解决方案5】:

            根据需要使用 PHP 函数 ucfirst、ucwords、strtoupper。

            ucfirst($row2['name']);
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2022-05-24
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2012-11-27
              • 1970-01-01
              相关资源
              最近更新 更多