Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of the get_defined_constants () function in PHP

Shulou Source: shulou.com Published: 2022-06-01 02:57:48 09月22日 Update

This article mainly introduces what is the use of the get_defined_constants() function in PHP. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

get_defined_constants()

Returns an associative array of all constants, where keys are constant names and values are constant values.

define("MY_CONSTANT", 1);

print_r(get_defined_constants(true));

// array(

// ……

// [user] => array(

// [MY_CONSTANT] => 1

// )

// )

This function will output all constants, because the return content is a lot, so use...... It means that there are many system or extension defined constants, and the constants we define ourselves in the code will all enter the key name [user].

This function takes one argument, and when it is true, lets the function return a multidimensional array of keys classified in the first dimension, constants and their values in the second dimension. The default is false and returns a one-dimensional array of constant names as keys and their values as keys.

Thank you for reading this article carefully. I hope that Xiaobian will share the "get_defined_constants() function in PHP". This article is helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Tags: Constant function article array one-dimensional code value interest content parameter at the same time under the name masterpiece that is situation more friends knowledge system tape Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn NVidia OPPO Reno Apple Shulou Information