previousPEAR::_PEAR() (Previous) (Next) PEAR::registerShutdownFunc()next

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

PEAR::getStaticProperty()

PEAR::getStaticProperty() – Maneja propiedades estáticas (package developer related)

Synopsis

require_once 'PEAR.php';

mixed &PEAR::getStaticProperty ( string $class , string $var )

Description

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');
?>
Debes emplear una referencia, o no persistirá

Parameter

  • string $class - el nombre de tu clase, donde llamas getStaticProperty()

  • string $var variable a devolver.

Return value

mixed - Una referencia a la variable. Si no se fija, será auto inicializada a NULL.

Example

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
previousPEAR::_PEAR() (Previous) (Next) PEAR::registerShutdownFunc()next

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.