Get the App
SLTechnology News&Howtos  ›  Development  › 

How PHP defines constant arrays through const and define ()

Shulou Source: shulou.com Published: 2022-06-01 02:37:36 09月27日 Update

This article will explain in detail how PHP defines constant arrays through const and define(). Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.

Define constant arrays by const and define()

const ARR1 = [1, 2, 3]; //const defines constant array print_r(ARR1); //Array ([0] => 1 [1] => 2 [2] => 3)define ('ARR2 ', [1, 2, 3]); //define() defines constant array print_r(ARR2); //Array ([0] => 1 [1] => 2 [2] => 3)//Application scenario: Upload error array information of custom file define ('CUSTOM_UPLOAD_ERRORS', [ 'ext_error' => 'file extension does not conform to specification','maxsize' => ' upload file size does not conform to specification']);//When file extension does not conform to specification when uploading, call echo CUSTOM_UPLOAD_ERRORS['ext_error'], "\n";//file extension does not conform to the specification about "PHP how to define constant arrays by const and define()" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Tags: Array constant file extension article more good practical information content scene size article time knowledge error adjustable reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft Apple OPPO Reno Shulou Information