Jump to content

Linking stylesheets with PHP problem


satterfield.ben

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.