getenv is returning false (only sometimes) |
![]() (This post was last modified: 12-13-2022, 11:49 AM by sarvap. Edit Reason: Removed the invalid image URL )
Recently downloaded CodeIgniter 4 and planning to move my websites from CI3 to 4.
In a controller function, where I check whether the user is logged, build image URL with S3 bucket domain, I use `getenv` to retrieve the value stored at .env file. In addition to this function, I retrieve values from .env using getenv() function in many other places in other controller functions, library and model functions as well. It was working well and suddenly at one controller function, the getenv() is returning (bool) false. This controller function is called via AJAX, and I tested by both GET and POST methods. 1. The value is correct and using same case. 2. The same function works properly 50% of the time when called via AJAX and directly on the browser and 50% of the time getenv() returns false. When the save value is retrieved by using $_ENV and $_SERVER, the values are available correctly. Only the getenv() is returning (bool) false. Code: echo "Var dump of getenv "; Output: https://prnt.sc/D8BhX2wQKWo6 Am I using getenv() in a wrong way or should I be not relying on getenv() always? |
Welcome Guest, Not a member yet? Register Sign In |