Home > Backend Development > PHP Tutorial > 大家帮忙看一下这段简单的代码哪里有问题

大家帮忙看一下这段简单的代码哪里有问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:15:03
Original
1043 people have browsed it

    private function getUserInfo(callable $Human)    {        try {            $users = (new $Human)->getUser()['users'];            $underageUsers = [foreach ($users as $user) if ($user->age < 18) yield $user];                        list($userNames, $ages) = array_map(                function($value) {return array_column($value, array('userNames', 'ages'), default);},                 mb_convert_encoding($underageUsers, 'utf-8', 'gbk')            );                        return ['name' => $userNames, 'surname' => $ages];        } catch(Exception $e) {            error_log($e);        }    }
Copy after login


回复讨论(解决方案)

callable 是什么?给出定义!

callable 是一个提示占位符.
说明参数是可以调用的资源体 

这个代码真心时尚啊,一堆php 5.5的特性。

$underageUsers是一个数组,什么时候mb_convert_encoding可以接受一个数组作为参数了

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template