Mailinglisten-Archive |
Enrico Weigelt schrieb:
>> class foo {
>>
>> public static function __call($method){
>> echo $method;
>> }
>> }
> Was genau bewirkt das 'static' ?
Alle Instanzen dieser Klasse teilen sich die
gleiche Methode. Statische Variablen eines Objekts
sind somit im anderen Objekt zugreifbar. Beispiel:
<?php
class foo {
public static function bar($var = FALSE) {
static $stor;
if($var) $stor = $var;
else echo $stor;
}
}
$foo = new foo();
$yetAnotherFoo = new foo();
$foo->bar('test');
$yetAnotherFoo->bar(); //gibt "test" aus
?>
Gruss,
Andreas
--
http://www.andreas-demmer.de
php::bar PHP Wiki - Listenarchive