Framework: getenv() and env() returns different results on string

Created on 10 Dec 2016  路  5Comments  路  Source: laravel/framework

  • Laravel Version: 5.3
  • PHP Version: 5.6
  • Database Driver & Version:

Description:

It looks like env() should returns the same value as getenv() but in some case it doesn't
https://github.com/laravel/framework/pull/16742

Steps To Reproduce:

in .env file add TEST="\"123 456\""

Then check output of :

getenv('TEST') => "123 456" 
env('TEST') => 123 456

Most helpful comment

@GrahamCampbell the same shitty answer as always. What the heck this kid is doing?!

All 5 comments

Yes. They are different functions.

getenv is laravel's one

getenv() is native PHP, env() is laravel's one.

Description of env() is

/**
 * Gets the value of an environment variable. Supports boolean, empty and null.
 **/

env() is good because it is an improved function built on top of getenv(), it also supports a default value, Output should be different in case of bool, empty and null but strings should be the same or maybe better explain if it is intentional.

Right, yeh, but laravel's is intentionally not the same, and intentionally does not enforce it's changes in the other function.

@GrahamCampbell the same shitty answer as always. What the heck this kid is doing?!

Was this page helpful?
0 / 5 - 0 ratings