Skip to content

Instantly share code, notes, and snippets.

@lduboeuf
Created May 19, 2015 09:20
Show Gist options
  • Save lduboeuf/571bc66f3f713804d56e to your computer and use it in GitHub Desktop.
Save lduboeuf/571bc66f3f713804d56e to your computer and use it in GitHub Desktop.
utilisation objet php
//TypeFilm.php est le fichier qui contient la déclaration de la classe TypeFilm
include('TypeFilm.php');
//creation de 2 instances, ici le constructeur de la classe permet de créer un TypeFilm avec un code et un libellé.
$tFilm = new TypeFilm("AVE", "Aventure");
$tFilm2 = new TypeFilm("COM", "Comedie");
//ajout au tableau (collection)
$ltypeFilms = array();
array_push($ltypeFilms, $tFilm);
array_push($ltypeFilms, $tFilm2);
//affichage
var_dump($ltypeFilms);
//ou parcours un a un
foreach ($ltypeFilms as $tf) {
echo $tf->getLibelle();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment