freude
12.03.2008, 09:46:14
Hallo,
ich habe folgendes Beispielskript:
class test {
public $a;
/**
* Constuctor
*/
function __construct() {
$this->a = 0;
}
function b(){
$this->a = 1;
}
function c(){
echo "<br>c:". $t->a;
$this->a = 2;
}
}
$t = new test();
echo "<br>a:". $t->a;
$t->b();
echo "<br>b:". $t->a;
$t->c();
echo "<br>d:". $t->a;
und dann kommt dieses Ergebnis:
a:0
b:1
c:
d:2
Meine Frage ist jetzt, warum Methode c nichts ausgibt. Warum ist die Variable a nicht innerhalb des ganzen Objektes aber außerhalb verfügbar und wie stelle ich es an, dass es so ist? Vielen Dank schon mal im Voraus.
freude
---> doofer Schreibfehler
ich habe folgendes Beispielskript:
class test {
public $a;
/**
* Constuctor
*/
function __construct() {
$this->a = 0;
}
function b(){
$this->a = 1;
}
function c(){
echo "<br>c:". $t->a;
$this->a = 2;
}
}
$t = new test();
echo "<br>a:". $t->a;
$t->b();
echo "<br>b:". $t->a;
$t->c();
echo "<br>d:". $t->a;
und dann kommt dieses Ergebnis:
a:0
b:1
c:
d:2
Meine Frage ist jetzt, warum Methode c nichts ausgibt. Warum ist die Variable a nicht innerhalb des ganzen Objektes aber außerhalb verfügbar und wie stelle ich es an, dass es so ist? Vielen Dank schon mal im Voraus.
freude
---> doofer Schreibfehler