php 載入的檔案 css js回傳給html沒有效果是什麼問題呢?
P粉477388163
P粉477388163 2022-06-13 15:10:01
0
4
1290

PHP程式碼

          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內容

html{
  font-size: 100px;
}

html內容

自动换行    
<!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 是這樣載入css檔案的:

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

拆解/res/public/css/style.css

/res/ 模組

取得真實路徑  www\app\public\res\css\style.css 並讀取回傳內容。

實際樣式沒有應用成功

1.png

2.png

#這是為什麼呢?跪求高手解答

P粉477388163
P粉477388163

全部回覆(1)
大瓶可乐

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

  • 回覆 沒用,任何樣式都沒有應用成功。只是內容是讀取的。
    P粉477388163 作者 2022-06-14 07:43:17
  • 回覆 http://127.0.0.1/res/public/css/style.css 你這件事是偽靜態呀
    大瓶可乐@php.cn 作者 2022-06-14 12:10:18
  • 回覆 可以吧css 寫入到文件裡面 下次在判斷文件是否存在,存在就不用去寫入了!然後直接正常css引用那個CSS文件
    大瓶可乐@php.cn 作者 2022-06-14 12:12:57
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!