I'm upgrading an exsiting application from php 5.3 to php 7.
I found this code in the application $this->upload_err = ERR_CORRUPTION;
I didn't found any const whith the name ERR_CORRUPTION
can we use string without quotes in PHP 5 ?
I'm upgrading an exsiting application from php 5.3 to php 7.
I found this code in the application $this->upload_err = ERR_CORRUPTION;
I didn't found any const whith the name ERR_CORRUPTION
can we use string without quotes in PHP 5 ?
Copyright © 2021 Jogjafile Inc.
Yes and no...
Somewhere during the development of PHP 3.0 (in 1998), a feature was added to allow unquoted strings; but before 3.0 came out, a different feature was added with the same syntax: constants.
Although the unquoted strings were never in a released version of PHP, they were retained as a fallback: PHP would first check if there was a constant with that name, and if not, treat it as a string. Whenever it fell back, it would issue an E_NOTICE, but a lot of people ignored these.
In PHP 7.2, the severity was raised to an E_WARNING, and the feature was officially deprecated. In PHP 8.0, it was raised to an Error.
So, this code was never technically correct, and the capital letters suggest that a constant definition was intended; but in PHP versions below 8.0, it will run even if the constant is undefined, acting as though you had run
define('ERR_CORRUPTION', 'ERR_CORRUPTION');