So basically I understand this …
class User
{
function __construct($id) {}
}
$u = new User(); // PHP would NOT allow this
I want to be able to do a user look up with any of the following parameters, but at least one is required, while keeping the default error handling PHP provides if no parameter is passed …
class User
{
function __construct($id=FALSE,$email=FALSE,$username=FALSE) {}
}
$u = new User(); // PHP would allow this
Is there a way to do this?
You could use an array to address a specific parameter:
And how you can use this: