help thx

Boncz Szilard
Boncz Szilard used Ask the Experts™
on
I must create PHP CLASS USER with this values : id, first_name, last_name, age. Class must have: constructor of class Method that returns the name of the user Method that returns a boolean value about user age validation can you help me? Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Here is a sample
<?php
class user
{
  protected $id;
  protected $first_name;
  protected $last_name;
  protected $age;

  public function __construct($id, $first_name, $last_name, $age)
  {
    $this->id = $id;
    $this->first_name = $first_name;   
    $this->last_name = $last_name;
    $this->age = $age;
  }
  public function getFirstName()
  {
    return $this->first_name;
  }

  public function isAgeValid()
  {
      return ($this->age > 1 && $this->age < 99);
  }
}

$person = new User(1, 'Fred', 'Smith', 21);
echo "Hello " . $person->getFirstName();
If (!$person->isAgeValid()) {
  echo "Please can I see some ID";
}

Open in new window

Author

Commented:
Thank you
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
@Boncz, I see you are a new addition to the EE community apologies for not welcoming you earlier.

It appears from your last comment that you are happy with the solution. If you have received an answer to your question the next step is to close the question. You can do this by clicking the button "Assisted Solution" (if you think more than one answer is valid - not really an option in this case - but for future reference) and "Best Solution" for the answer that best answers the question. If only one post answers the question then simply click "Best Solution" on that answer and follow the wizard.

Look forward to seeing more of you on the forums
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Author

Commented:
Ahhh sorrry thx
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
No problem - but could I ask you to grade it again. At EE we try to make questions useful to the next person who comes along - so the accepted answer needs to relate to the question. If you could rather accept the first comment as it relates to the question - that would be great.

Thanks

Author

Commented:
Usefull

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial