简体   繁体   中英

How does the core 'php.ini' directive 'memory_limit' is considered as an 'Environment Variable' in an code example from the PHP Manual?

I'm using PHP 7.2.8 on my machine that runs on Windows 10 64-bit Operating System .

I come across the following code example from PHP Manual having some description :

Using environment variables can be used in php.ini as shown below.

Example #1 php.ini Environment Variables

 ; PHP_MEMORY_LIMIT is taken from environment memory_limit = ${PHP_MEMORY_LIMIT} 

I executed the above code on my machine it gave me the following error messages :

Warning: Use of undefined constant PHP_MEMORY_LIMIT - assumed 'PHP_MEMORY_LIMIT' (this will throw an Error in a future version of PHP) in demo.php on line 3

Notice: Undefined variable: PHP_MEMORY_LIMIT in demo.php on line 3

I checked the list of available 'Environment Variables' on my machine but I didn't get such environment variable named $_ENV['PHP_MEMORY_LIMIT']

Then, I checked the php.ini file present on my machine. I found the core php_directive memory_limit=128M

So, my question is why the code example from PHP Manual is considering something similar( ${PHP_MEMORY_LIMIT} ) to the core 'php.ini' directive as an 'Environment Variable' ?

Also, the code written in this code example doesn't work as such environment variable named ${PHP_MEMORY_LIMIT} doesn't exist.

I even checked the latest php.ini from Git as recommended in the PHP Manual but in that file also I found the core php_directive memory_limit=128M and no environment similar to it.

Is the PHP Manual having wrong code example?

Someone please clear my doubts.

Thanks.

The first thing to note is that your example is not a code example, it's a configuration example. So it belongs on php.ini and not on a PHP file.

Environment variables are system dependent and it is up to you to set them. The manual is giving you an example with the aptly named PHP_MEMORY_LIMIT . You could set that variable on your system and then use it on your php.ini . But you can call it whatever you want, that's just an example, it's not based on any specific platform where that variable would be set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM