So, I understand that sometimes people use parens and sometimes they don’t when declaring an instance of a class as an object.
If I declare a class without arguments and then extend it to have arguments, will the initial class need to have had parens?
Furthermore, can I have a class with brackets and no specific parameter or reference variable declaration like this:
$myObject = clone ClassName();
And then use parameters for the class….
class User($param, $param2)
Or do classes ever even use parameters? I’m not really sure because there isn’t an example of a class that takes parameters in my book….
Those parameters, eg
dont correspond to the class declaration, they relate to the constructor. An example:
So basically the reason you dont see a class declaration with parameters is because they dont exist, the class constructor is where the parameters go.