8

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);
}
mtr.web
9107 silver badges18 bronze badges
asked Jul 13, 2018 at 14:46
0

5 Answers 5

13

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);
}
answered Jul 13, 2018 at 14:50
2
  • 1
    You can't just change core files. Also this is probably not the only issue with 7.2 Commented 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 ! Commented Dec 8, 2018 at 14:59
8

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.

ProcessEight
1,0101 gold badge8 silver badges20 bronze badges
answered Jul 13, 2018 at 20:23
4

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.

answered Jul 15, 2018 at 20:08
4

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) {

answered Sep 28, 2018 at 8:27
1

just please change your PHP version to 7.0 it will start working fine.. don't forget PHP (CLI) also must be 7.0

answered Mar 20, 2019 at 14:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.