The problem is easy to explain. What I want to do is to create an object, parameters and function calls based on $_POST variables.
$obj = new $_POST['object']['name']($_POST['object']['params']);
return json_encode(
$obj->$_POST['function']['name']($_POST['function']['params'])
);
The only problem here is that it gives the parameters as an array. And I want it to seperate the variables with a comma, like: $obj->function($var1 , $var2, $var3);. How can I achieve this?
The best way is to create object without arguments passed to constructor and initiate it using some other method. For example:
Also, in PHP 5.4+ you can use this “hack”:
But I advise you to change your architecture so you would be able to pass array to constructor “as is”.