Valid XHTML     Valid CSS2    

Listing du fichier oo_inc.php

 

00001     <?php
00002     
# (gH) -_- oo_inc.php ; TimeStamp (unix) : 11 Janvier 2013 vers 19:50
00003     
00004     #############################################################################
00005     
00006     
class personne {
00007     
00008     
#############################################################################
00009     
00010     
private
$prenom ;
00011     private
$nom ;
00012     
00013     
# ----------------------------------------------
00014     
00015     
function
__construct($lePrenom="",$leNom="") {
00016     
$this
->prenom = $lePrenom ;
00017     
$this
->nom = $leNom ;
00018      echo
"Bonjour
$lePrenom $leNom.\n" ;
00019     }
# fin de function __construct
00020     
00021     # ----------------------------------------------
00022     
00023     
function
get_prenom() {
00024      return(
$this
->prenom ) ;
00025     }
# fin de fonction get_prenom
00026     
00027     
function
set_prenom($lePrenom="") {
00028     
$this
->prenom = $lePrenom ;
00029     }
# fin de fonction set_prenom
00030     
00031     # ----------------------------------------------
00032     
00033     
function
get_nom() {
00034      return(
$this
->nom ) ;
00035     }
# fin de fonction get_nom
00036     
00037     
function
set_nom($leNom="") {
00038     
$this
->nom = $leNom ;
00039     }
# fin de fonction set_nom
00040     
00041     # ----------------------------------------------
00042     
00043     
function
identite() {
00044      echo
"NOM =
$this->nom ; PRENOM = $this->prenom.\n";
00045     }
# fin de fonction identite {
00046     
00047     # ----------------------------------------------
00048     
00049     
function
enTableau() {
00050      return( array(
$this
->nom,$this->prenom ) ) ;
00051     }
# fin de fonction enTableau {
00052     
00053     # ----------------------------------------------
00054     
00055     
function
enXml_1() {
00056     
$chXml
= "<personne>" ;
00057     
$chXml
.= " <prenom> $this->prenom </prenom>" ;
00058     
$chXml
.= " <nom> $this->nom </nom>" ;
00059     
$chXml
.= "</personne>" ;
00060      return(
$chXml ) ;
00061     }
# fin de fonction enXml_1 {
00062     
00063     # ----------------------------------------------
00064     
00065     
function
enXml_2() {
00066     
$domtree
= new DOMDocument() ;
00067     
$rootElt
= $domtree->createElement("personne") ;
00068     
$tmp
= $domtree->appendChild($rootElt) ;
00069     
$pre
= $domtree->createElement("prenom",$this->prenom) ;
00070     
$tmp
= $rootElt->appendChild($pre);
00071     
$nom
= $domtree->createElement("nom",$this->nom) ;
00072     
$tmp
= $rootElt->appendChild($nom) ;
00073     
$chXml
= $domtree->saveXML() ;
00074      return(
$chXml ) ;
00075     }
# fin de fonction enXml_2 {
00076     
00077     # ----------------------------------------------
00078     
00079     
function
__destruct() {
00080      echo
"Au revoir.\n" ;
00081     }
# fin de function __destruct
00082     
00083     
} # fin de classe personne
00084     
00085     #############################################################################
00086     #############################################################################
00087     
00088     
class
equipe {
00089     
00090     
#############################################################################
00091     
00092     # mettre ici un tableau de personnes...
00093     
00094     
} # fin de classe equipe
00095     
00096     
?>

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)