【问题标题】:Insert custom CSS class into function?将自定义 CSS 类插入函数?
【发布时间】:2015-08-22 11:48:25
【问题描述】:

我想在该代码上使用我的自定义 CSS 样式,有什么想法应该怎么做?

        //Load modules
        if ($handle = opendir('modules'))
        {
            while (false !== ($file = readdir($handle)))
            {
                if ($file != "." && $file != "..")
                {
                    $replace = preg_replace( array ('/(.*?)/', '/[-]/', '/.php/'), array ('$1', ' '), $file);
                    $result = ucfirst($replace);
                    echo '<a href="?inav=';
                    echo $replace;
                    echo '">';
                    echo $result;
                    echo '</a><br>';

                }
            }
            closedir($handle);

我想插入:

<a href="?inav=" class="button101"><span class="user icon">

【问题讨论】:

  • 您的问题到底是什么?回显字符串class="button101"?!或者你想让 PHP 为.button101 生成 CSS 类定义? (你当然不应该那样做,但在&lt;head&gt; 中回显&lt;link rel="stylesheet" type="text/css" href="path/to/stylesheet.css"/&gt;)。

标签: php class spawn


【解决方案1】:

只需添加您需要的回声:

    //Load modules
    if ($handle = opendir('modules'))
    {
        while (false !== ($file = readdir($handle)))
        {
            if ($file != "." && $file != "..")
            {
                $replace = preg_replace( array ('/(.*?)/', '/[-]/', '/.php/'), array ('$1', '&nbsp;'), $file);
                $result = ucfirst($replace);
                echo '<a href="?inav=';
                echo $replace;
                echo '"';
                echo ' class="button101"';
                echo '>';
                echo $result;
                echo '</a><br>';

            }
        }
        closedir($handle);

【讨论】:

  • 好吧tnx,但你也忘记了 class="user icon"!
猜你喜欢
  • 2018-09-18
  • 1970-01-01
  • 2018-02-04
  • 2023-03-14
  • 1970-01-01
  • 2020-09-03
  • 2015-08-06
  • 2014-11-20
  • 1970-01-01
相关资源
最近更新 更多