0

I ran into a problem when working with PHP buffer. The essence of the problem: when you connect an HTML file in which there is a CSS file connection, CSS is not displayed on the page. I double-checked the code, and through the inspector of the elements, too - in the browser this CSS file is opened by reference without any problems, the paths are correct. I was looking for a problem with Google but I didn’t find anything.

    ob_start();
    require $filePath;
    ob_get_flush();

and required files.

    <link rel="stylesheet" href="<?= ROOT ?>css/main.css">
Niroshan Ratnayake
  • 3,433
  • 3
  • 20
  • 18
Wembley
  • 27
  • 6
  • `ob_get_flush();` probably retunrs the string, but your code doesn't do anything with it. Try `echo ob_get_flush();` or assign to variable and check its value other way. – shudder Apr 05 '20 at 13:53
  • shudder, due to echo, the contents are called twice. CSS is still not output. – Wembley Apr 05 '20 at 14:16
  • How do you know contents are called twice? You said nothing is displayed. – shudder Apr 06 '20 at 04:57
  • i mean nothing from CSS... Page is displayed WITHOUT CSS styles, but CSS included correctly. – Wembley Apr 06 '20 at 13:39
  • So html response contains correctly included line with stylesheet directive? That means php works fine. Make sure your `ROOT` translates to absolute path to the file (with domain and https if you use one). Check network response to css request in browser's developer tools (`F12` usually). Also look at answers to [this question](https://stackoverflow.com/questions/9480773/html-not-loading-css-file) – shudder Apr 06 '20 at 16:59
  • As I said before, CSS is connected correctly and when you go through the element inspector, it opens normally. type="text/css" tried too. Nope( – Wembley Apr 06 '20 at 18:26

0 Answers0