-2

I am new to PHP 7 and i have an issue on my class ,i work with Hapedit and here is the source code

<?php  header("Content-type: text/html; charset=ISO-8859-1");
  class Personne {
  protected $_nom;
  protected $_prenom;
  protected $_dateNaissance;
  protected $_salaire;  }

   function __getNom($_nom){
    return $this->$_nom;
   }
   function __getPrenom($_prenom){
   return $this->$_prenom;
   }
   function __getdateNaissance($_dateNaissance){
   return $this->$_dateNaissance;
   }
   function __getSalaire($_salaire){
   return $this->$_salaire;
   }
   //setters
   function __setNom($nom)
   {
   $this->_nom = $nom;
   }
   function __setPrenom($prenom)
   {
   $this->_prenom = $prenom;
    }
  function __setdateNaissance($dateNaissance)
  {
  $this->_dateNaissance = $dateNaissance ;
  }
  function __setSalaire($salaire)
  {
  $this->_salaire = $salaire;
  }
   //méthode pour afficher des informations sur la personne en question
  function info(){
   echo 'La personne a comme nom ' .$this->_nom . 'et prenom ' . $this- 
   >_prenom. ' est ne en ' .$this->_dateNaissance. ' et a comme salaire ' . 
   $this->_salaire;
   }
  //declaration d’un objet Personne
  $_perso = new Personne()
  $_perso->setNom('Rossafi');
  $_perso->setPrenom('Ahmed');
  $_perso->setdateNaissance('1991');
  $_perso->setSalaire('5000');
  $_perso->info();
 ?>

My goal is to create a class Personne and first of all to show all info of a person with the method info()

And i have this error:

Parse error: syntax error, unexpected '$_perso' (T_VARIABLE) in C:\xampp\htdocs\www\TPPHPObjet1\Personne.php on line 53

Can you help please? Thank you

underscore_d
  • 6,309
  • 3
  • 38
  • 64
Zebra
  • 17
  • 7
  • 1
    Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – user3942918 Apr 13 '18 at 19:46

1 Answers1

0

You're missing a semicolon.

  //declaration d’un objet Personne
  $_perso = new Personne()  <---- there should be a semicolon here
  $_perso->setNom('Rossafi');
  $_perso->setPrenom('Ahmed'); 

Suggest you use a IDE like netbeans, phpstorm or zend studio. They will highlight such issues and you'll be able to see what's on line 53

Further your class is ending before the methods. This is how I believe your class is trying to be structured.

class Personne
{
    protected $_nom;

    protected $_prenom;

    protected $_dateNaissance;

    protected $_salaire;

    function __getNom($_nom)
    {
        return $this->$_nom;
    }

    function __getPrenom($_prenom)
    {
        return $this->$_prenom;
    }

    function __getdateNaissance($_dateNaissance)
    {
        return $this->$_dateNaissance;
    }

    function __getSalaire($_salaire)
    {
        return $this->$_salaire;
    }

    //setters
    function __setNom($nom)
    {
        $this->_nom = $nom;
    }

    function __setPrenom($prenom)
    {
        $this->_prenom = $prenom;
    }

    function __setdateNaissance($dateNaissance)
    {
        $this->_dateNaissance = $dateNaissance;
    }

    function __setSalaire($salaire)
    {
        $this->_salaire = $salaire;
    }

    //méthode pour afficher des informations sur la personne en question
    function info()
    {
        echo 'La personne a comme nom ' . $this->_nom . 'et prenom ' . $this->_prenom . ' est ne en ' . $this->_dateNaissance . ' et a comme salaire ' . $this->_salaire;
    }
}

Again, an IDE is helpful here because it'll help keep the formatting readable.

Moak
  • 12,596
  • 27
  • 111
  • 166