How to figure out the paths, why the styles are not applied, the file is not found, I tried many methods, but as a rule nothing works, it happens that the main page applies styles, in other files there is none or there is no file at all, it is clear that you need to register the paths, but how? I tried $path = $_SERVER['DOCUMENT_ROOT']; this does not work

Can you please show us your code and explain what the expected behavior is and what is not working?

$_SERVER['DOCUMENT_ROOT']; reflects the path on the server that serves as the root path / for the website. When you set $path = $_SERVER['DOCUMENT_ROOT']; you are setting a PHP variable named $path to whatever the value of the document root is, but it doesn't actually do anything with that beyond set the variable.

It's possible you're using a CMS or framework of some kind that does something with a $path variable, but without seeing any code, it wouldn't do anything.

Also, when you say styles, are you referring to the theme files for a CMS? Or CSS stylesheets? I'm not sure what you're referring to here.

To resolve path issues in PHP, ensure your CSS files are correctly linked using absolute paths like base_url/style.css or relative paths based on your folder structure. Use echo $_SERVER['DOCUMENT_ROOT'] to debug and confirm the correct path to your files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.