Created
May 19, 2015 09:20
-
-
Save lduboeuf/571bc66f3f713804d56e to your computer and use it in GitHub Desktop.
utilisation objet php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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