Php 7.2 and php7.2

Source: Internet
Author: User

Php 7.2 and php7.2

<?php$b = array();each($b);// Deprecated:  The each() function is deprecated. This message will be suppressed on further calls

The each function is set to obsolete in php7.2,

<?phpcount('');// Warning:  count(): Parameter must be an array or an object that implements Countable

The count function strictly separates execution types in php7.2. If the input type is incorrect, a warning is triggered.

<?php$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');echo "New anonymous function: $newfunc\n";echo $newfunc(2, M_E) . "\n";// outputs// New anonymous function: lambda_1// ln(2) + ln(2.718281828459) = 1.6931471805599// Warning This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

The create_function has been set to obsolete in php7.2.


Bytes -----------------------------------------------------------------------------------------------------------


function fun_adm_each(&$array){   $res = array();   $key = key($array);   if($key !== null){       next($array);        $res[1] = $res['value'] = $array[$key];       $res[0] = $res['key'] = $key;   }else{       $res = false;   }   return $res;}

Replace each.


function fun_adm_count($array_or_countable,$mode = COUNT_NORMAL){    if(is_array($array_or_countable) || is_object($array_or_countable)){        return count($array_or_countable, $mode);    }else{        return 0;    }}

Replace count.


<?php    $fun = function ($str ){echo $str}    $fun('Yuan');

Replace create_function.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.