Was ist das Problem, wenn die von PHP, CSS, JS geladene und an HTML zurückgegebene Datei keine Wirkung hat?
P粉477388163
P粉477388163 2022-06-13 15:10:01
0
4
1293

PHP-Code

          ob_end_clean();
          ob_start();

          //读取文件mimetype信息
          $finfo = finfo_open(FILEINFO_MIME);
          $mimetype = finfo_file($finfo, $uri);
          finfo_close($finfo);

          //打开文件
          $file    = fopen($uri, 'r');
          $file_size  = filesize($uri);
          //声明头信息
          Header("Content-type: $mimetype");
          Header("Accept-Ranges: bytes");
          Header("Accept-Length: ".$file_size);
         
          // 输出文件内容
          echo fread($file,$file_size);
          fclose($file);

CSS-Inhalt

html{
  font-size: 100px;
}

HTML-Inhalt

自动换行    
<!DOCTYPE html>    
<html lang="zh-CN">    
<head>    
<meta charset="UTF-8">    
<meta http-equiv="X-UA-Compatible" content="IE=edge">    
<meta name="viewport" content="width=device-width, initial-scale=1.0">    
<link rel="stylesheet" href="http://127.0.0.1/res/public/css/style.css">    
<title>test</title>    
</head>    
<body>    

hello world

     </body>     </html>

php lädt die CSS-Datei wie folgt:

http://127.0.0.1/res/public/css/style.css.

Zerlegen Sie das Modul /res/public/css/style.css

/res/

Ermitteln Sie den tatsächlichen Pfad wwwapppublicrescssstyle.css und lesen Sie den zurückgegebenen Inhalt.

Der eigentliche Stil wurde nicht erfolgreich angewendet

1.png

2.png

Warum ist das so? Ich bitte die Experten um Antworten

P粉477388163
P粉477388163

Antworte allen(1)
大瓶可乐

html{font-size:100px} 换成 p呢?

  • Antwort 没用,任何样式都没有应用成功。只是内容是读取到的。
    P粉477388163 Autor 2022-06-14 07:43:17
  • Antwort http://127.0.0.1/res/public/css/style.css 你这个是一个伪静态呀
    大瓶可乐@php.cn Autor 2022-06-14 12:10:18
  • Antwort 可以吧css 写入到文件里面 下次在判断文件是否存在,存在就不用去写入了! 然后直接正常css引用那个CSS文件
    大瓶可乐@php.cn Autor 2022-06-14 12:12:57
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!