- json_encode: documentation ( source)
<?php
class Geolocation {
function myMethod($param1, $param2) {
return $param1 . ' ' . $param2;
}
}
$method = 'myMethod';
$params = [1, 2];
$geo = new Geolocation();
$res = $geo->{$method}(...$params);
echo json_encode($res);