title: Setting PHP headers within function / class method
body: <p>I have written a class which outputs content type information as a header, however this does not work.  After reading PHP.net it states </p>
  
  <blockquote>
    <p>Remember that header() must be called before any actual output is
    sent, either by normal HTML tags, blank lines in a file, or from PHP.
    It is a very common error to read code with include(), or require(),
    functions, or another file access function, and have spaces or empty
    lines that are output before header() is called.</p>
  </blockquote>
  
  <p>I am unsure what to do as I cannot hard code the content type everywhere needed.  Does anyone know if it is possible to set headers in functions / classes at all?</p>