|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-01-07 13:20 UTC] michael dot vorisek at email dot cz
Description: ------------ php.ini configuration is currently quite flexible, it allows variables, binary bitwise operations etc. But currently there is no way to write conditional expressions. This is feature request for: - null colleasing operator (very usefull for empty enviroment variables to assign some default value instead) - ternary operator (for general conditions) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
memory_limit = 32M memory_limit = "${PHP_MEMORY_LIMIT}" I have tested this and currently this config does not ignore the 2nd line if the variable is not set, i.e. it does not use "last default/correct value" but instead it uses "PHP default value" Ternary operator is definitely needed for these cases or is there currently any solution without using shell before PHP is launched?> The sentence actually means that if you typo the *name* of the directive, PHP will not complain and a default value will be used instead. Yes, but it does not actually use default value it uses empty string - it should be documented this way also. My specific use case is to set some PHP config value thru env. vars for **recursive** PHP execution, i.e. to be able to pass some configuration values to php subprocess started by exec('php ...') of which I do not have any control and this seems to me like the only way without extra shell script. I propose adding ternary "a ? b ? c" and null colleasing operators "a ?? b". Both operators should evaluate if the "a" expression is empty (i.e. zero length or "0") Then fallback will be easy to implement like: memory_limit = ${PHP_MEMORY_LIMIT} ?? "32MB"