PHP.nl

uopz_set_property

uopz_set_property

Sets value of existing class or instance property

void **uopz_set_property** string $class string $property mixed $value
void **uopz_set_property** object $instance string $property mixed $value

Sets the value of an existing static class property, if is given, or the value of an instance property (regardless whether the instance property already exists), if is given. class``instance

classThe name of the class.

instanceThe object instance.

propertyThe name of the property.

valueThe value to assign to the property.

return.void

Voorbeeld: Basic Usage

<?php
class Foo {
   private static $staticBar;
   private $bar;
   public static function testStaticBar() {
      return self::$staticBar;
   }
   public function testBar() {
      return $this->bar;
   }
}
$foo = new Foo;
uopz_set_property('Foo', 'staticBar', 10);
uopz_set_property($foo, 'bar', 100);
var_dump(Foo::testStaticBar());
var_dump($foo->testBar());
?>
int(10)

uopz_get_property