# Php for browser styles

**URL:** <https://forum.kirupa.com/t/php-for-browser-styles/283766>\
**Category:** Uncategorized\
**Created:** [March 10, 2009, 9:57pm UTC](https://forum.kirupa.com/t/php-for-browser-styles/283766 "2009-03-10T21:57:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![polymaze](https://avatars.discourse-cdn.com/v4/letter/p/9de0a6/32.png) [@polymaze](https://forum.kirupa.com/u/polymaze)\
**Post date:** [March 10, 2009, 9:57pm UTC](https://forum.kirupa.com/t/php-for-browser-styles/283766/1 "2009-03-10T21:57:15Z")

</div>

Does anyone know the correct way of serving up css styles for different browsers as external links, particularly ie7, with php?

I think it should work something like this:

```auto

<?php
    
    $agent = getenv("HTTP_USER_AGENT");
    
    $style = "<link rel=\"stylesheet\" href=\"resources/style.css\" type=\"text/css\" media=\"projection, screen\" charset=\"utf-8\" />";
    
    if (preg_match("/MSIE 7/i", "$agent")) {
        $style = "<link rel=\"stylesheet\" href=\"resources/ie7.css\" type=\"text/css\" media=\"projection, screen\" charset=\"utf-8\" />";
    }
    
?>

<?php echo $style; ?>

```

for some reason, this seems to give ie7 the same stylesheet as all the other browsers.

thank you  
any help is appreciated.
