Joshua
Joshua

Reputation: 6853

Problem With Constructors With Parameters In PHP

class MyClass {
  function __constructor($A,$B,$C) {
    echo("$A $B $C");
  }
}
$MC=new MyClass('Hello','World','!');

My parameters don't seem to be making it through to the constructor... Am I doing this wrong?

Upvotes: 0

Views: 128

Answers (1)

Tyler Carter
Tyler Carter

Reputation: 61587

Its __construct()

class MyClass {
  function __construct($A,$B,$C) {
    echo("$A $B $C");
  }
}
$MC=new MyClass('Hello','World','!');

https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor

Upvotes: 5

Related Questions