Question: I am attempting to store css files inside database and call them in the most effective wa using PHP. I know I can include a style.php file and just do a query to get the data; however, not sure if that is the best way or not. I'd prefer to not have 

```
<style>
#blah { }
#blah 2 { }
etc.
</style>

```

show up on every page. I am attempting to make this work similar to how a typical css file would work where it is just a link similar to the way it is below. I have read about people using 
html page:

```
<link rel="stylesheet" type="text/css" href="style.php" />

```

style.php page:

```
header("Content-Type: text/css");

```

however, have also seen that that doesn't work well with IE.

So does anyone have any recommendations on how I can do this in the best way for all browsers?

Answer: 
I'd probably write a tiny wrapper class for each:

```
template <class T>
class read_only {
    T volatile *addr;
public:
    read_only(int address) : addr((T *)address) {}
    operator T() volatile const { return *addr; }
};

template <class T>
class write_only { 
    T volatile *addr;
public:
    write_only(int address) : addr ((T *)address) {}

    // chaining not allowed since it's write only.
    void operator=(T const &t) volatile { *addr = t; } 
};

```

At least assuming your system has a reasonable compiler, I'd expect both of these to be optimized so the generated code was indistinguishable from using a raw pointer. Usage:

```
read_only<unsigned char> x(0x1234);
write_only<unsigned char> y(0x1235);

y = x + 1;         // No problem

x = y;             // won't compile

```
In C, you can use pointers to incomplete types to prevent all dereferencing: 

---

```
/* writeonly.h */
typedef struct writeonly *wo_ptr_t;

```

---

```
/* writeonly.c */
#include "writeonly.h"

struct writeonly {
  int value 
};

/*...*/

   FOO_REGISTER->value = 42;

```

---

```
/* someother.c */
#include "writeonly.h"

/*...*/

   int x = FOO_REGISTER->value; /* error: deref'ing pointer to incomplete type */

```

---

Only `writeonly.c`, or in general any code that has a definition `struct writeonly`, can dereference the pointer. That code, of course, can accidentally read the value also, but at least all other code is prevented from dereferencing the pointers all together, while being able to pass those pointers around and store them in variables, arrays and structures.

`writeonly.[ch]` could provide a function for writing a value.