PHP Constructor not called when creating

It seems to me that my PHP class constructor will not be called when the class starts. This is what my constructor looks like:

public function __contruct()
{
  $GLOBALS['page_content'] .= "<p>Constructor entered.</p>\r\n";

  try
  {
    $this->ConstructorBase();
  }
  catch ( Exception $e )
  {
    throw new Exception(
      "Error in ".__FILE__."(".__LINE__."): Constructor failed.",
      CLoginError::ERROR_CANNOT_INSTANTIATE, $e );
  }
}

Later in the same file, in the global scope, I try to instantiate a class:

$Login = new CLogin();

However, when I check $GLOBALS['page_content'], after creating the class instance it is empty, as if the constructor had never been called. What is strange is that I can call public member functions. If you want to see it, the full source is available here:

http://pastebin.com/D95YnUmS

+5
source share
1 answer

You named your function __contruct()where it should be . This is a very common mistake, you should probably get some sleep.__construct()

+54

All Articles