php - Accessing object variable via double dollar sign -
I am creating a square to create variables so that another php file can be easily created.
The problem is that I get $ variable_name = & gt; I'm using double dollars to make. $$ varible_real_value Style hashp and I want all the Iterator features to be square variables __Constructor defining a new variable in the scope can overwrite the variable from the files. The problematic piece of code is
foreach ($ this-> Args AS $ this-> iterator) {$ this-> Data-> $ The-> iterator = $$ this-> Iterator; } But when I call it
foreach ($ this-> args as $ var) {$ this-> Data-> $ Var = $$ var; } The variable '$ var' will be overwritten.
class DataFile {private $ data = zero, $ iterator = null, $ args = null; Public function __ conversion ($ file) {requirement ($ file); Not set ($ file); $ This- & gt; Args = funny_gate_argain (); ($ This-> args) array_shift; $ This- & gt; Data = new ArrayObject (); Forex Currency ($ this-> Args AS $ this-> Iterator) {$ this-> Data-> $ The- & gt; Iterator = $$ this-> Iterator; }} Public Function __get ($ key) {Return $ this- & gt; Data-> $ Key; }} example usage:
$ conf = new data file ('mysql.php', 'var'); $ Databasename = $ conf- & gt; Var- & gt; Database; Is there any alternative solution for this,
thanks
$ this-> Data-> $ This- & gt; Iterator is ambiguous What do you mean by $ this- & gt; Data is the property of whose name is $ it-> iterator or iterator property $ this- & gt; Data-> $ This ? You should clarify it:
$ this-> Data-> {$ This-> Iterator} goes to the same $$ it-> iterator .
Comments
Post a Comment