Jump to content

__autoload()


c_pattle

Recommended Posts

I'm trying to use the autoload class but am having some trouble.  Here is my autoload class,

 

function __autoload($class_name) {
    include("classes/" . $class_name . ".class.php");
}

 

The problem I am having is that when I include this class at the top of this page I then keep getting this error - "Warning: Cannot modify header information - headers already sent by" whenever I try to start a session or use the "header" function but I'm not sure why that's happening because surely I haven't echoed anything yet. 

 

Thanks for any help. 

Link to comment
Share on other sites

Sure.  Here is my index page

 

<?php
require_once("includes/inc_theme.php");

session_start();
include("classes/autoloadClass.class.php");

 

By starting the session before I include the autoload class I don't get the error anymore but I still get the error when I try to use the header function late down the page. 

Link to comment
Share on other sites

Sorry.  If I change my index.php file to this

 

require_once("includes/inc_theme.php");
include("classes/autoloadClass.class.php");
session_start();

 

Then I get these error messages. 

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/webemail/classes/autoloadClass.class.php:9) in /var/www/webemail/index.php on line 4

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/webemail/classes/autoloadClass.class.php:9) in /var/www/webemail/index.php on line 4

 

It's saying that the error is appearing on line 9 of my autoload class put that line doesn't exist.  It only goes up to line 8.  This is my autoload class again. 

 

<?php

function __autoload($class_name) {
    include("classes/" . $class_name . ".class.php");
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.