Ooookay.
So, I have this annoying issue. I’m calling a css file within an php/html doc and I’m getting strange results – probably because I’m failing to understand something.
I’ve defined a few constants in my application (constants.php):
define("ROOT", dirname(dirname(__FILE__)));
define("DS", DIRECTORY_SEPARATOR);
define("RESOURCES", ROOT . DS . "resources" . DS);
define("CSS", RESOURCES . "css" . DS );
My folder structure looks something like:
Localhost (development root folder. FYI: it is C:\Users\Kyle\SkyDrive\www)
Framework
library (folder)
constants.php (file)
resources (folder)
CSS (folder)
wuxia-blue.css
views (folder)
Booking (folder)
dashboard.php (file)
Now, in my dashboard.php file I’m linking the css folder as follows:
<link rel='stylesheet' type='text/css' href="">
Now comes the issue: when I use href=”/framework/resources/css/wuxia-blue.css”, the css pulls perfectly fine and all looks great. Only problem is, I want to pull it with something like:
href="<?php echo(CSS); ?>wuxia-blue.css"
That resolves to C:\Users\Kyle\SkyDrive\www\Framework\resources\css\wuxia-blue.css which is the correct path to the resource but when I use it, no CSS pulls through on the page.
Any ideas?
This is because your CSS constant contains the root.
You could just str_replace this though