?php include "storageclasses.inc"; / / some utilty functions function p_arr($arr) {foreach($arr as $k= $v) $out[] = "\t$k = $v"; return implode("\n", $out);} function object_info($obj) {$out[] = "Class: ".get_class($obj); foreach(get_object_vars($obj) as $var= $val) if (is_array($val)) $out[] = "property: $var (array)\n".p_arr($val); else $out[] = "property: $var = $val"; foreach(get_class_methods($obj) as $method) $out[] = "method: $method"; return implode("\n", $out);} $data = array(M_PI, "kludge != cruft"); / / we create some basic objects $fs = new FileStorage($data); $ws = new WDDXStorage($data); / / print information on the objects echo "\$fs object\n"; echo object_info($fs) ."\n"; echo "\n\$ws object\n"; echo object_info($ws) ."\n"; / / do some aggregation echo "\nLet's aggregate \$fs to the WDDXStorage class\n"; aggregate($fs, "WDDXStorage"); echo "\$fs object\n"; echo object_info($fs) ."\n"; echo "\nNow let us aggregate it to the DBStorage class\n"; aggregate($fs, "DBStorage"); echo "\$fs object\n"; echo object_info($fs) ."\n"; echo "\nAnd finally deaggregate WDDXStorage\n"; deaggregate($fs, "WDDXStorage"); echo "\$fs object\n"; echo object_info($fs) ."\n";?
?php include "storageclasses.inc"; / / quelques utilitaires function p_arr($arr) {foreach($arr as $k= $v) $out[] = "\t$k = $v"; return implode("\n", $out);} function object_info($obj) {$out[] = "Classe: ".get_class($obj); foreach(get_object_vars($obj) as $var= $val) if (is_array($val)) $out[] = "propri eacute;t eacute;: $var (array)\n".p_arr($val); else $out[] = "propri eacute;t eacute;: $var = $val"; foreach(get_class_methods($obj) as $method) $out[] = "m eacute;thode: $method"; return implode("\n", $out);} $data = array(M_PI, "kludge != cruft"); / / cr eacute;ons quelques objets simples $fs = new FileStorage($data); $ws = new WDDXStorage($data); / / affichons des informations sur ces objets echo "\$fs object\n"; echo object_info($fs) ."\n"; echo "\n\$ws object\n"; echo object_info($ws) ."\n"; / / maintenant, quelques aggr eacute;gations echo "\nAggr eacute;geons \$fs avec la classe WDDXStorage\n"; aggregate($fs, "WDDXStorage"); echo "L'objet \$fs \n"; echo object_info($fs) ."\n"; echo "\nAggr eacute;geons le r eacute;sultat avec la classe DBStorage \n"; aggregate($fs, "DBStorage"); echo "L'objet \$fs \n"; echo object_info($fs) ."\n"; echo "\nEt finalement, d eacute;saggr eacute;geons WDDXStorage\n"; deaggregate($fs, "WDDXStorage"); echo "L'objet \$fs \n"; echo object_info($fs) ."\n";?