PHP underscore code error, help to see

Source: Internet
Author: User
Return a copy of the array with falsy values removed public  function compact ($collection =null) {    list ($collecti ON) = Self::_wrapargs (Func_get_args (), 1);        $collection = Self::_collection ($collection);        $__ = new Self;    Return Self::_wrap ($__->select ($collection, function ($val) {      return (bool) $val;    }));  }

function ($val) {

Code from PHP underscore, this place error, does not seem to be able to do parameters.

Reply content:

Return a copy of the array with falsy values removed public  function compact ($collection =null) {    list ($collecti ON) = Self::_wrapargs (Func_get_args (), 1);        $collection = Self::_collection ($collection);        $__ = new Self;    Return Self::_wrap ($__->select ($collection, function ($val) {      return (bool) $val;    }));  }

function ($val) {

Code from PHP underscore, this place error, does not seem to be able to do parameters.

function ($val) {

This notation is a function of lambda functions (anonymous functions), which used to appear in the scripting languages such as JS. However, starting with PHP 5.3, this anonymous function is supported. So you have a problem is not enough PHP version, upgrade to the latest version of PHP 5.3.x can solve this problem.

  • Related Article

    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: info-contact@alibabacloud.com 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.