I’m trying to link to an external stylesheet using this code:
<?php
include("/homepages/9/myusername/htdocs/Mobile_Detect.php");
$detect = new Mobile_Detect();
if($detect->isiOS()){
// code to run for the Apple iOS platform.
echo '<link rel="stylesheet" type="text/css" href="/homepages/9/myusername/htdocs/style.css" />';
}
?>
Unfortunately, I can’t seem to establish a working link to style.css. I’ve tried this absolute path, as well as an ordinary path, formatted as if it were HTML: href="/style.css", href="style.css", href="./style.css", and every other possibility. What am I doing wrong? How can I make this code work?
The
hrefattribute of astyletag is processed by a browser. Browser obviously doesn’t have access to your server filesystem path/homepages/9/whatever(even more, it will try to loadhttp://yoursite/homepages/9/whatever).Change the value of
hrefattribute with something browser is able to load (e.g.http://yoursite/media/style.css).