tivrfoa Posted August 14, 2009 Share Posted August 14, 2009 hey folks! <?php error_reporting(E_ALL); ini_set('display_errors', 1); class A { public $aProperty; } class B { private $a; function __construct() { $this->a = new A(); $this->a->aProperty = 'A property'; } function get($attribute) { return $this->$attribute; } } $b = new B(); echo $b->get('a')->aProperty; // work echo $b->get('a->aProperty'); // doesn't work echo '<p>the end</p>'; ?> How can I make the code that doesn't work work? Thank you!! Link to comment https://forums.phpfreaks.com/topic/170215-dynamic-attribute-eval-a-string-attribute-of-attribute/ Share on other sites More sharing options...
Mark Baker Posted August 14, 2009 Share Posted August 14, 2009 Write your own language that supports the syntax you want to use? Link to comment https://forums.phpfreaks.com/topic/170215-dynamic-attribute-eval-a-string-attribute-of-attribute/#findComment-897935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.