![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
Simulate Static Class Variable...
Here is a little trick you can use to simulate static variables within a PHP class. PHP5 does not yet support static variables, though it does have support for static class functions.
$GLOBALS['_transient']['static']['test']->v1 = 1;
class Test {
function Test() {
$this->v1 = & $GLOBALS['_transient']['static']['test']->v1;
}
function printAndIncrease() {
echo "$this->v1<br>";
$this->v1++;
}
var $v1;
}
$t1 = new Test();
$t1->printAndIncrease();
$t2 = new Test();
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|