|
|
(Next) PEAR::registerShutdownFunc() |
||||
| |
|||||
|
|||||
mixed &PEAR::getStaticProperty (
string $class
,
string $var
)
Si tienes una clase que es mayor/completamente estática, y necesitas propiedades estáticas, puedes usar este método para simularlas. Pe. en tu(s) método(s) haz esto:
<?php
$myVar = &PEAR::getStaticProperty('myVar');
?>
string $class - el nombre de tu clase, donde llamas getStaticProperty()
string $var variable a devolver.
mixed - Una referencia a la variable. Si no se fija, será auto inicializada a NULL.
Usando getStaticProperty()
<?php
require_once 'PEAR.php';
class myClass {
function setValue( $set)
{
$foo = &PEAR::getStaticProperty('myClass', "foo");
$foo = $set;
}
function view()
{
print PEAR::getStaticProperty('myClass', "foo");
}
}
myClass::setValue('value = foo');
myClass::view();
?>
Esto imprimirá
value = foo
|
|
(Next) PEAR::registerShutdownFunc() |
||||||||
| |
|||||||||
|
|||||||||