func_get_args detect context

Posted by Steve on Stack Overflow See other posts from Stack Overflow or by Steve
Published on 2012-11-12T22:51:07Z Indexed on 2012/11/12 23:00 UTC
Read the original article Hit count: 158

Filed under:
|

I have a script where it accepts a varying number of arguments.

I want to use func_get_args to perform operations on said arguments. If I have one function like this:

function Something() {
   foreach(func_get_args($this) as $functions) {
       // Do something
   }

   // Return..
}

I want to be able to call this function in, for example, another function to add/save entries. The add/save function would have arguments 'title', 'description' etc..

I basically want to know if there is a way to detect the context of a function call. Can I pass something to func_get_args that will let it know that its called in a certain function? So if I do:

function Save($title, $desc) {
$vars = $this->Something();
}

I want $vars to contain $title and $desc after modifying them.

© Stack Overflow or respective owner

Related posts about php

Related posts about function