I have these three files:
index.php
<?php include('variables.php') ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>TestWebsite</title>
<link rel="stylesheet" href="<?php echo($folder . 'css/styles.css')?>">
</head>
variables.php
<?php
$folder = "C:/xampp/htdocs/Website/";
css/styles.css
/* Insert styling stuff here */
index.php and variables.php are stored on the root directory. For some reason the stylesheet refuses to link, and I need help with figuring out why. This works fine though:
<link rel="stylesheet" href="styles.css">
- Tried putting
<?php echo($folder . 'css/styles.css')?>into a separate php file to see if I appended the directory correctly. - Tried moving styles.css out of its parent folder into the main directory
- Tried
<link rel="stylesheet" href="<?php echo $folder ?>css/styles.css"> - In index.php there are include()s that use $folder and work just fine.
- Am starting to wonder if its a scope issue
You do not have a protocol specified for the local file path. In that case, it is the protocol path
file://.Instead of an absolute URL, it is more appropriate to enter a relative URL and view your test pages via a "simple web server" (e.g. Built-in web server).