Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Referencje i zmienne static
cagrET
post 6.12.2003, 15:39:58
Post #1





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 3.04.2003
Skąd: Opole

Ostrzeżenie: (0%)
-----


Otoz jest taki kawalek kodu php:

[php:1:28e0ae4307]
<?php

class Test {

function &factory() {
return new Test;
}

function &singleton() {
static $instance;
if (!isset($instance)) {
$instance =& Test::factory();
}
return $instance;
}

}

$Test1 =& Test::singleton();
$Test1->aaa = 1;

$Test2 =& Test::singleton();

print_r($Test1);
print_r('<br>');
print_r($Test2);

?>
[/php:1:28e0ae4307]

i wyswietla on:

Kod
test Object ( [aaa] => 1 )

test Object ( )


Dlaczego ?


--------------------
code.gosu.pl
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 15.08.2025 - 17:41