1.2.395. Dynamic Property

Dynamic access to class property. This is when the the name of the property is stored in a variable (or other container), rather than statically provided.

<?php

class x {
    static public $foo = 1;
           public $bar = 2;
}

$staticproperty = 'foo';
// dynamic static property call to x::$foo
echo x::${$staticproperty};

$property = 'bar';
// dynamic property call to bar()
$object = new x();
$object->$property = 4;

?>

See also class.

1.2.395.1. Specs

Short name

Classes/DynamicPropertyCall

Rulesets

All, Appinfo, CE

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

class

Available in

Entreprise Edition, Community Edition, Exakat Cloud