In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to solve the laravel project local environment PHP7 error each function waste problem, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
Example 1:
Php7.1 writing method
If (is_array ($u)) {while (list ($key) = each ($u)) {$u = $u [$key]; break;}}
Change to php7.2 writing method
If (is_array ($u)) {$u = current ($u);} As PHP7.2 says, I suggest to use foreach () function as a substitute of deprecated each (). Here I let a couple of examples that works to me in Wordpress.---- as PHP7.2 said, I recommend using the foreach () function instead of the deprecated each (). Here are a few examples that are useful to me in Wordpress.
(OLD) while (list ($branch, $sub_tree) = each ($_ tree)) {.} (NEW) foreach ((Array) $tree as $branch = > $sub_tree) {.} (OLD) while ($activity = each ($this- > init_activity)) {.} (NEW) foreach ($this- > init_activity as $activity) {.} (old) while (list ($file) $info) = each ($this- > images)) (new) foreach ($this- > images as $file = > $info) {/ /.}
Example 2
16548 while (list ($id, $name) = each ($attr_ array [1]) {/ / 7.1I replaced the line with the next code in both lines and it worked, replaced by the following foreach ($attr_array [1] as $id = > $name) {/ / 7.2
Example 3: my example: an error occurred while generating a signature during payment
Public function createLinkString ($param) {$arg = ""; / / array sort ksort ($param); reset ($param); / / 7.1Writing / * while (list ($key, $val) = each ($param)) {if ($key = "sign") continue; if (! empty ($key)) {$arg. = $key. "=";} if (is_array ($val)) {$arg. = $this- > createLinkString ($val). Else {$arg. = $val. Write foreach ($param as $key = > $val) {if ($key = = "sign") continue; if (! empty ($key)) {$arg. = $key. "=";} if (is_array ($val)) {$arg. = $this- > createLinkString ($val). Else {$arg. = $val. "&";}} / / remove the last & character $arg = substr ($arg, 0, strlen ($arg)-1); return $arg;}
In short, in the php7.2 version, the each function is obsolete and cannot be used, so it is ok to replace it with foreach.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.