开发者

PHP constant case

开发者 https://www.devze.com 2023-02-18 06:46 出处:网络
I was wondering if I can set a pre defined parameter value in PHP to lower case instead of upper case as in the example below?

I was wondering if I can set a pre defined parameter value in PHP to lower case instead of upper case as in the example below?

Example 1 -开发者_开发百科 upper case:

imagefilter($im, IMG_FILTER_GRAYSCALE)

Example 2 - lower case:

imagefilter($im, img_filter_grayscale)


A constant is case-sensitive by default

see PHP manual: Constants

And why would you want to do this?


constants, like IMG_FILTER_GRAYSCALE, are case-sensitive in PHP per default (http://php.net/manual/en/language.constants.php)


I think this is only achievable if you define the wanted lowercase name with the uppercase name, hence that would not be useful and you are/will create duplicated pieces of code, while not necessary..

why would you want to do this anyway ?

Info about PHP constants can be found here Constants

0

精彩评论

暂无评论...
验证码 换一张
取 消