Skip to content
Advertisement

Any way to simplify PHP constructor arguments?

When I want to pass values into a PHP constructor I have to go:

JavaScript

is there a simpler way to do it? something like

JavaScript

Advertisement

Answer

JavaScript

or:

JavaScript

or:

JavaScript

But really, rather than saving a line or two and trying to be clever, using explicit assignment is usually preferred because it’s very easy to understand, even if boring. If you find that you have too many arguments to type out one by one, maybe you have too many arguments.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement