getVar() behavior on Windows and Linux |
$this->request->getVar("id") in a controller works for GET request parameters only on my local env - Windows 10 / Apache / PHP8
On Ubuntu 20 / Nginx / PHP8 i get `undefined` for the same request Replacing it with getGet("id") solves the problem PHP Code: return $this->respond([ Response: Code: GET: {id: "1", data: "{"status":"0"}"} Isn't it a bug? Because documentation says: "The getVar() method will pull from $_REQUEST, so will return any data from $_GET, $POST, or $_COOKIE (depending on php.ini request-order)."
Check the request_order value in phpinfo().
If G is not set, GET values are not set in $_REQUEST.
Okay, no problem.
I don't know why you can't get with getVar(). Did you checked the $_REQUEST value? Quote:request_order string Your $_REQUEST should have GET and POST values. This is not CodeIgniter matter, but PHP matter. It is very wired that your $_REQUEST is an empty array. (12-30-2022, 12:06 AM)kenjis Wrote:Quote:request_order string It is a default Ubuntu 20 / Nginx / PHP-FHM 8.1 setup No customization I agree that it is not a CI issue, but better to warn users that getVar/REQUEST depends not only on `request_order` (12-30-2022, 01:40 AM)kenjis Wrote: Please try this: No, i don't want my code to depend on any server environment I will use getGet() for GET requests
Okay, no problem.
I think it is better not to use getVar(), because if you use it, you don't know the value where comes from exactly. It might cause security issues, although I do not believe the risk is high. |
Welcome Guest, Not a member yet? Register Sign In |