0
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?

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

2 Comments

Additionally, if you are used to C++ or C#, you can also use name of the class as the name of constructor.
Oops! How Embarrassing! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.