I have been getting this error since I changed to PHP-7.2
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /var/www/html/vedic/vendor/colinmollenhour/cache-backend-file/File.php on line 81
The function is on line 81.
//Don't use parent constructor
while (list($name, $value) = each($options)) {
$this->setOption($name, $value);
}
5 Answers 5
each() function is deprecated in php 7.2 so change this function to foreach()
Change
while (list($name, $value) = each($options)) {
$this->setOption($name, $value);
}
To
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
-
1You can't just change core files. Also this is probably not the only issue with 7.27ochem– 7ochem2018年07月15日 09:35:47 +00:00Commented Jul 15, 2018 at 9:35
-
Magento 2.3 now supports PHP 7.2, but this answer helped me fix an issue with a 3rd party extension, thanks !David– David2018年12月08日 14:59:06 +00:00Commented Dec 8, 2018 at 14:59
Magento 2 does not support PHP 7.2 until version 2.3 which is not out yet (rumour is it'll be out by the end of 2018).
So your only real option here is to downgrade to the latest supported version of PHP (check the DevDocs for your version of Magento: https://devdocs.magento.com/guides/v2.2/install-gde/prereq/prereq-overview.html#php).
You could also ignore this error and run the risk of hitting other compatibility issues but that wouldn't be advisable. There will likely be many more errors across your site.
As mentioned above Magento before 2.3 (unreleased yet) doesn't support PHP 7.2.
There is a separate repo tracking support for PHP 7.2 https://github.com/magento-engcom/php-7.2-support it's maintained by Magento 2 core team. I'm not sure yet if it was merged to https://github.com/magento/magento2/tree/2.3-develop branch.
Instead of the below line you can add new line
Old Line
while (list($name, $value) = each($options)) {
Paste the below new line
foreach ($options as $name => $value) {
just please change your PHP version to 7.0 it will start working fine.. don't forget PHP (CLI) also must be 7.0
Explore related questions
See similar questions with these tags.