Using headers in a class
<p>I access a function in an included class Environment which can throw an Alert which needs to direct the users back to a page with some error information. What is the best way for me to reference the page so it can be used wherever I access the function from anywhere?</p>

<p>Is there any better way to do what I am trying to do?</p>

<pre><code>public function checkEnvironment() {

        try {

            // If status is false
            if (!$this-&gt;getStatus()) {

                // Generate a new special exception with code
                throw new Alert(6);

            } else {

                $connection = Gateway::checkInstance();

                return $connection-&gt;getData('SELECT * FROM control_environment WHERE subdomain = ?', array($this-&gt;subdomain[0]));

            }

        } catch (Alert $alert) {

            $_SESSION['error'] = $alert-&gt;getData();

            if (!headers_sent()) {

                header('Location: my/file/here.php');

                exit;
            }

        }

    }
</code></pre>
