getVar() behavior on Windows and Linux - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: getVar() behavior on Windows and Linux (/showthread.php?tid=85987) |
getVar() behavior on Windows and Linux - ruslan - 12-29-2022 $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)." RE: getVar() behavior on Windows and Linux - kenjis - 12-29-2022 Check the request_order value in phpinfo(). If G is not set, GET values are not set in $_REQUEST. RE: getVar() behavior on Windows and Linux - ruslan - 12-29-2022 request_order GP RE: getVar() behavior on Windows and Linux - kenjis - 12-29-2022 Okay, no problem. I don't know why you can't get with getVar(). Did you checked the $_REQUEST value? RE: getVar() behavior on Windows and Linux - ruslan - 12-29-2022 $_REUEST is empty Code: "id-get": "22", I guess the documentation should say that not only `request_order` affects getVar()/$_REQUEST content RE: getVar() behavior on Windows and Linux - kenjis - 12-30-2022 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. RE: getVar() behavior on Windows and Linux - ruslan - 12-30-2022 (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` RE: getVar() behavior on Windows and Linux - kenjis - 12-30-2022 Please try this: https://stackoverflow.com/questions/21622563/get-filled-but-request-is-empty RE: getVar() behavior on Windows and Linux - ruslan - 12-30-2022 (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 RE: getVar() behavior on Windows and Linux - kenjis - 12-30-2022 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. |