Premier commit
This commit is contained in:
44
Etudiant.php
Normal file
44
Etudiant.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Class Etudiant{
|
||||||
|
|
||||||
|
private $nom;
|
||||||
|
private $prenom;
|
||||||
|
private $age;
|
||||||
|
|
||||||
|
public function __construct($nom,$prenom,$age){
|
||||||
|
$this->nom = $nom;
|
||||||
|
$this->prenom = $prenom;
|
||||||
|
$this->age = $age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afficherHtml(){
|
||||||
|
echo "Etudiant2 :<br>". "Nom : ".$this->getNom()."<br>"
|
||||||
|
."Prenom : ".$this->getPrenom()."<br>"."Age : ".$this->getAge()."<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
//accès en écriture (setter)
|
||||||
|
public function setNom($nom){
|
||||||
|
$this->nom = $nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrenom($prenom){
|
||||||
|
$this->prenom = $prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAge($age){
|
||||||
|
$this->age = $age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNom(){
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrenom(){
|
||||||
|
return $this->prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAge(){
|
||||||
|
return $this->age;
|
||||||
|
}
|
||||||
|
}
|
13
EtudiantBachelor.php
Normal file
13
EtudiantBachelor.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "Etudiant.php";
|
||||||
|
|
||||||
|
Class EtudiantBachelor extends Etudiant{
|
||||||
|
private $tempsEveil = 15;
|
||||||
|
|
||||||
|
public function afficherHtml(){
|
||||||
|
echo "<br>Etudiant2 :<br>". "Nom : ".$this->getNom()."<br>"
|
||||||
|
."Prenom : ".$this->getPrenom()."<br>"."Age : "
|
||||||
|
.$this->getAge()."<br>"."Eveil : ;".$this->tempsEveil;
|
||||||
|
}
|
||||||
|
}
|
20
scripte1.php
Normal file
20
scripte1.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
include_once "scripte2.php";
|
||||||
|
require_once "Etudiant.php";
|
||||||
|
require_once "EtudiantBachelor.php";
|
||||||
|
|
||||||
|
//vérification des droits
|
||||||
|
// session -> vérif du rôle
|
||||||
|
// => si pas les droits : bye
|
||||||
|
|
||||||
|
//echo "script 1<br>";
|
||||||
|
|
||||||
|
$etu1 = new Etudiant("Dupont","Lorant","25");
|
||||||
|
//$etu1->setNom("Durant");
|
||||||
|
$etu1->afficherHtml();
|
||||||
|
|
||||||
|
$etu2 = new EtudiantBachelor("Dudu","Olivie","20");
|
||||||
|
|
||||||
|
$etu2->afficherHtml();
|
||||||
|
|
||||||
|
traitementPrive();
|
13
scripte2.php
Normal file
13
scripte2.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$a = "coincoin";
|
||||||
|
|
||||||
|
// n'apparei pas lors de l'appel
|
||||||
|
function traitementPrive(){
|
||||||
|
global $a; //indispensable pour accèder au variables globales
|
||||||
|
echo "<br><br>Dans script 2<br>";
|
||||||
|
echo "Super privé, super dangereux...<br>";
|
||||||
|
|
||||||
|
echo $a;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user