0

The error is:

Fatal error: Uncaught exception 'RuntimeException' with message 'Unexpected data in output buffer. Maybe you have characters before an opening

I have built a pretty simple controller class to handle the routing and rendering of an MVC I am working on. I register all the controllers in the container and setup the routes calling them like 'className:methodName' which is working. Each controller though needed a constructor to set the container so that I could render php view. This seemed like a good thing to dry up so I made an abstract class

abstract class Controller {
    public $container;

    function __constructor($container = null){
         $this->container = $container;
    }
}

Literally changes nothing just a layer of abstraction but this is when the above mentioned error occurs.

Which I can fix by adding the following setting:

addContentLengthHeader = false

Which is great because I can still work but I am not sure A) Why is the content length set is this some added security or something? and B) Why is this abstraction causing this to happen should I be doing something different?

Alessio
  • 3,404
  • 19
  • 35
  • 48
nerdlyist
  • 2,842
  • 2
  • 20
  • 32

1 Answers1

1

This error is presented when you have whitespace or other characters before or after the class declaration. Please check your source files for whitespace before the opening PHP tag

geggleto
  • 2,605
  • 1
  • 15
  • 18