0

I'm trying to make a very easy function to assign variables to a child variables of a function.

The best will be something like this :

$this->assign($param1, $param2, $param3);

and in the assign function:

public function assign(){
    $aArgs = func_get_args();

    foreach($aArgs as $key => $value){
        $this->data->{**NAME OF the arg (ex : param1)**} = $value;
    }
}

Nobody have a little trick or solution? (please don't say that's is impossible, try to make the impossible possible with creative solution like debug_backtrace etc ;-))

Fabio
  • 23,183
  • 12
  • 55
  • 64
injetkilo
  • 300
  • 2
  • 10
  • You should check [here](http://stackoverflow.com/questions/255312/how-to-get-a-variable-name-as-a-string-in-php), a lot of solutions are there for your problem. – Adrien Lacroix May 12 '13 at 12:36
  • if your function is not defined with those values is impossible. For example for a function defined like function(), but called like function("value1", "value2", "value3"), you will not be able to make it work. basicly when you call a function in php, you just send the values over, and they will or will not be allocated to some internal variables. If they are not allocated (aka function is not defined as having those variables as input), then is not possible to do it. – Xnoise May 12 '13 at 15:34

0 Answers0