Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
class User
{
private int $id;
private string $name;
public function __construct(int $id, string $name)
{
$this->id = $id;
$this->name = $name;
}
public function getId(): int
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function rename(string $name): void
{
$this->name = $name;
}
}
First you need to answer yourself the question - why do you need a user class.
If it's just "Schaub Bulo", then you don't need any class. Go for arrays.
When you understand why you need classes at all, then there will be an understanding of how to make a user class.
And no - 5 years in 5 minutes will not work.
And by the way, there is a high probability that understanding will not come either in 5 or 10 years. Out of a hundred users, it’s good if three master object-oriented programming. It's not scary, PHP is a democratic language, you can write OOP, you can sprinkle procedurals.
Only in the latter case, one should not try to deceive oneself and sculpt classes from manure and straw, as the Papuans did after the war (during the war, large iron pieces flew from the sky, and brought a bunch of goodies. Then there were no white people, and the goodies ran out The Papuans began to build entire airfields - with planes, hangars, tankers - all from sticks and straw, in the hope that nishtyaks would appear from the sky again. Because if you make an airplane without really understanding how it works, then it won't fly. And it will only superficially resemble the real one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question