What is the problem if the file loaded by php, css, js and returned to html has no effect?
P粉477388163
P粉477388163 2022-06-13 15:10:01
0
4
1341

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 content

html{
  font-size: 100px;
}

html content

自动换行    
<!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 Yes Load the css file like this:

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

Disassemble/res/public/css/style.css

/res/ Module

Get the real path www\app\public\res\css\style.css and read the returned content.

The actual style was not applied successfully

1.png

2.png

##Why is this? Woolen cloth? I beg the experts for answers

P粉477388163
P粉477388163

reply all(1)
大瓶可乐

html{font-size:100px} What about replacing it with p?

  • reply No use, none of the styles were successfully applied. Only the content is read.
    P粉477388163 author 2022-06-14 07:43:17
  • reply http://127.0.0.1/res/public/css/style.css This is a pseudo-static
    大瓶可乐@php.cn author 2022-06-14 12:10:18
  • reply Yes, you can write the css into the file. Next time, you will determine whether the file exists. If it exists, you don’t need to write it! Then directly reference that CSS file with normal css
    大瓶可乐@php.cn author 2022-06-14 12:12:57
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template