如何将css应用于php'echo $ tube->错误;'?

时间:2012-06-17 18:33:31

标签: php html css styles stylesheet

我试图附加到'echo $ tube->错误;'的CSS没有显示..它只显示为默认的黑色文本,好像它没有css ...我该怎么解决这个问题?

谢谢(:

以下是我需要解决的问题..

html / php部分:

<div id="error">
        <pre>
        <?php } else {

        echo $tube->error;

        }
    }
        ?>
    </pre>
</div>

上下文中的html / php部分:

<?php

if(isset($_POST['url']))
{
  include('curl.php');
  include('youtube.php');

  $tube = new youtube();

  $links = $tube->get($_POST['url']);

  if($links) { ?>

  <div id="result"> 
  <b>Download Links  ( Same IP Downloading only )</b> :
        <?php
        $format = '<p><a href="%3$s">Download</a> video.%s - %s<br/>Right-click download link and choose etc...</p>';
        while($link = array_shift($links))
{
    echo vsprintf($format,$link);
}
        ?>
  </div>
  <div id="error">
        <pre>
        <?php } else {

        echo $tube->error;

        }
    }
        ?>
    </pre>
</div>

CSS:

#error {
    width:404px;
    margin-left: auto;
    margin-right: auto;
    font-size:12;
    font-family: 'Dosis', sans-serif;
    color:white;
    padding-top:20px;   
}

youtube.php的一部分(附加信息..不确定你们是否需要这个):

function get($url)
{
    $this->conn = new Curl('youtube');

    $html = $this->conn->get($url);

    if(strstr($html,'verify-age-thumb'))
    {
        $this->error = "Adult Video Detected";
        return false;
    }

    if(strstr($html,'das_captcha'))
    {
        $this->error = "Captcah Found please run on diffrent server";
        return false;
    }

    if(!preg_match('/stream_map=(.[^&]*?)&/i',$html,$match))
    {
        $this->error = "Error Locating Downlod URL's";
        return false;
    }

再次感谢您的帮助!!

5 个答案:

答案 0 :(得分:3)

编辑:我错了,这不是一个CSS错误,而是一个构造错误,正如其他人注意到的那样。我刚刚重写了“上下文中的html / php部分”,以使其更清晰,更有希望工作:

<?php

if(isset($_POST['url']))
{
  include('curl.php');
  include('youtube.php');

  $tube = new youtube();

  $links = $tube->get($_POST['url']);

  if($links) 
  { 
    ?>
    <div id="result"> 
      <b>Download Links  ( Same IP Downloading only )</b> :
      <?php
      $format = '<p><a href="%3$s">Download</a> video.%s - %s<br/>Right-click download link and choose etc...</p>';
      while($link = array_shift($links))
      {
        echo vsprintf($format,$link);
      }
      ?>
    </div>
    <?php 
  } 
  else 
  {
    ?>
    <div id="error">
      <pre>
      <?php echo $tube->error; ?>
      </pre>
    </div>
    <?php
  }
}
?>

希望现在一切正常:)

答案 1 :(得分:2)

如果出现错误,您的<div id="error">永远不会呈现,因为您的else语句只包含错误文本本身。将divpre移到else内以使其正常工作。

<?php } else { ?>
  <div id="error">
    <pre>
       <?php echo $tube->error; ?>    
    </pre>
  </div>
<?php } ?>

答案 2 :(得分:2)

试试这段代码:

<?php
if (isset($_POST['url'])) {
    include('curl.php');
    include('youtube.php');

    $tube = new youtube();

    $links = $tube->get($_POST['url']);

    if ($links) {
?>
<div id="result"> 
<b>Download Links  ( Same IP Downloading only )</b> :
<?php
    $format = '<p><a href="%3$s">Download</a> video.%s - %s<br/>Right-click download link and choose etc...</p>';
    while($link = array_shift($links)) {
        echo vsprintf($format,$link);
    }
?>
</div>
<?php } else { ?>
<div id="error">
    <pre>
    <?php echo $tube->error; ?>
    </pre>
</div>
<?php } } ?>

不要忘记包含CSS ...请在将来写出更多可读性。

答案 3 :(得分:0)

试试这个css:

#error pre {
    width:404px;
    margin-left: auto;
    margin-right: auto;
    font-size:12;
    font-family: 'Dosis', sans-serif;
    color:white;
    padding-top:20px;   
}

答案 4 :(得分:0)

尝试为#error pre定义CSS,而不仅仅是#error

div#error {
    width:404px;
    margin-left: auto;
    margin-right: auto;
    padding-top:20px;   
}

div#error pre
{
    font-size:12;
    font-family: 'Dosis', sans-serif;
    color:white;
}

还可以使用检查员(如Chrome的那个,用CTRL + I调用)来确保: - 没有覆盖撤消那些行 - 正确加载CSS(如果在外部文件中)