I have a class, which has a __constructor method. I use this constructor method in several places so don’t want to remove it yet. I could make a create method instead and this is what I’ll eventually do.
I want to however also have a getById method where my object is created by a database query
[code]
class person{
private string $personName;
public function __construct($personName){
$this->personName = $personName;
}
public function getById($id){
//do database stuff
$this->personName = $row[‘personName’];
}
}
On my pages I want this
[code]
$person = new person;
$person->getById($_GET[‘id’]);
But I’m getting this error **Fatal error: Uncaught ArgumentCountError: Too few arguments to function
Is there a way around this?