satterfield.ben Posted December 4, 2006 Share Posted December 4, 2006 Alright, unsure how to categorized this problem but hopefully someone will know what I'm trying to do and give me some input. We are developing a template web design for a bunch of projects coming down the pipe but I have hit a snag.I am trying to reference a stylesheet from an include folder. The php code that I'm using in my /includes/header.php is [color=blue]<link rel="stylesheet" type="text/css" href="<?php echo 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/css/global.css' ?>" />[/color]The code works well until I start organizing my files into folders. On my index.php I use this code [color=blue]<?php include ('http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/includes/header.php'); ?>[/color]That changes the .dirname($_SERVER['PHP_SELF']) of my stylesheet reference to "includes/css/global.css" instead of "css/global.css" The easy fix would to just hard code my URL,but I kinda need to figure this one out. If I remove the "dirname($_SERVER['PHP_SELF'])" and further add the location it works until I move this template into a working project into a different folder which is why we were using the code in the first place. If someone could throw an idea or even label my problem so that I can Google it.Thanks a bunch.Ben Satterfield Link to comment https://forums.phpfreaks.com/topic/29403-linking-stylesheets-with-php-problem/ Share on other sites More sharing options...
makeshift_theory Posted December 4, 2006 Share Posted December 4, 2006 Hi Ben, on your index file where you have dirname, use this instead echo dirname($_SERVER["REQUEST_URI"]), See if that works better for you. Link to comment https://forums.phpfreaks.com/topic/29403-linking-stylesheets-with-php-problem/#findComment-134964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.