Voting

: min(nine, four)?
(Example: nine)

The Note You're Voting On

davidn at xnet dot co dot nz
16 years ago
Static variables are shared between sub classes

<?php
class MyParent {

protected static
$variable;
}

class
Child1 extends MyParent {

function
set() {

self::$variable = 2;
}
}

class
Child2 extends MyParent {

function
show() {

echo(
self::$variable);
}
}

$c1 = new Child1();
$c1->set();
$c2 = new Child2();
$c2->show(); // prints 2
?>

<< Back to user notes page

To Top