I am working on my local machine. I have folders containing different sites within my document root.
My file structure looks like this:
index.php
css/layout.css
includes/header.php
includes/footer.php
includes/functions.php
company/index.php
Inside my functions.php file I declare a global variable as follows:
$docRoot = $_SERVER['DOCUMENT_ROOT'] . '/website';
At the top of each index.php file I include functions.php in addition I also include header.php and footer.php.
Now in my header.php file I am trying to link to my css file as follows:
<link rel="stylesheet" type="text/css" href="<?php echo $docRoot . "/css/layout.css"; ?> />
which results in the following: <link rel=“stylesheet” type=“text/css” href=“C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/website/css/layout.css” />
However, the styles don’t take effect. The styles would undoubtedly load properly on a live server, however, I work on my local development server and then move to the live server. I need a solution that will allow for development and easy migration.
Additionally, if I load the styles as follows:
<style type="text/css">
<?php include_once $docRoot . "/css/layout.css"; ?>
</style>
They work properly on the mainpage index.php file only because of the relative paths of the images within the css file.
Anyone have a better solution for this?
Thanks