class DateTime {/ / same as previous example} class DateTimePlus {var $_format; function DateTimePlus($format="Y-m-d H:i:s") {$this - _format = $format} function now() {return date($this - _format);}} class Report {var $_dt; / / we'll keep the reference to DateTime here / / more properties... function Report() {/ / do some initialization} function setDateTime ($dt) {$this - _dt = $dt;} function generateReport() {$dateTime = $_dt - now(); / / more code...} / / more methods...} $rep = new Report(); $dt = new DateTime(); $dtp = new DateTimePlus("l, F j, Y (h:i:s a, T)"); / / generate report with simple date for web display $rep - setDateTime ($dt); echo $rep - generateReport(); / / later on in the code... / / generate report with fancy date $rep - setDateTime ($dtp); $output = $rep - generateReport(); / / save $output in database / /... etc...
?php class DateTime {/ / identique au pr eacute;c eacute;dent exemple} class DateTimePlus {var $_format; function DateTimePlus($format="Y-m-d H:i:s") {$this - _format = $format} function now() {return date($this - _format);}} class Report {var $_dt; / / Nous allons garder la r eacute;f eacute;rence agrave; DateTime ici / / autre propri eacute;t eacute;s function Report() {/ / initialisation} function setDateTime ($dt) {$this - _dt = $dt;} function generateReport() {$dateTime = $_dt - now(); / / autre code...} / / autres m eacute;thodes...} $rep = new Report(); $dt = new DateTime(); $dtp = new DateTimePlus("l, F j, Y (h:i:s a, T)"); / / G eacute;n eacute;ratino du rapport avec une simple date $rep - setDateTime ($dt); echo $rep - generateReport(); / / plus loin dans le code / / generation du rapport avec une date design eacute;e $rep - setDateTime ($dtp); $output = $rep - generateReport(); / / sauvegarde pour affichage dans la base / /... etc...?