Exception or error:
Hi call_user_func
is used in my existing code but it is throwing an INTERNAL SERVER ERROR
$out=call_user_func($func);
$func
variable has an array like this.
Array
(
[0] => MetricName Object
(
[idplot] =>
[_idtestType:MetricName:private] =>
[data] =>
[idmetricName] =>
[queriesForIds:MetricName:private] => Array
(
[idviewType] => SELECT column FROM Table WHERE idColumn =
[idworstCase] => SELECT column2 FROM Table2 WHERE idColumn =
)
)
[1] => update
)
class MetricName {
function update() {
//Its not possible to add the code inside the update method
}
}
This method is throwing INTERNAL SERVER ERROR
Undefined index: environment
Don’t know how to fix this error.
How to solve:
How to use function call_user_func_array
reference visite https://www.php.net/manual/pt_BR/function.call-user-func-array.php
<?php
class MetricName {
function update($ds) {
print_r($ds);
}
}
$func = [
new MetricName(),'update',
];
call_user_func_array ($func,['234']);
?>