I created the API action below: (v2024)
$app->get('/GetEmpInfo[/{uno}]', function ($request, $response, $args) {
$uno = $args["uno"] ?? null;
if ($pfno !== null) {
$sql = "select * from employees where pfno = ".$uno;
$info = ExecuteRow($sql);
}else{
$info = (0);
}
return $response->withJson($info);
});
On running via URL: http://localhost/myapp/api/getempinfo/2
it returns a value of zero i.e. it does not pick the 2.
When I put an echo statement to determine the value of $args["uno"]
, I get the error undefined array key.
I have no idea what I am missing.
Any help would be highly appreciated.