Phpunderscore code error.

Source: Internet
Author: User
{Code...} function ($ val) {code comes from phpunderscore. An error is reported in this area and it seems that no parameter can be set.
// Return a copy of the array with falsy values removed  public function compact($collection=null) {    list($collection) = self::_wrapArgs(func_get_args(), 1);        $collection = self::_collection($collection);        $__ = new self;    return self::_wrap($__->select($collection, function($val) {      return (bool) $val;    }));  }

Function ($ val ){

The Code comes from php underscore. An error is reported in this area and it does not seem to support parameters.

Reply content:
// Return a copy of the array with falsy values removed  public function compact($collection=null) {    list($collection) = self::_wrapArgs(func_get_args(), 1);        $collection = self::_collection($collection);        $__ = new self;    return self::_wrap($__->select($collection, function($val) {      return (bool) $val;    }));  }

Function ($ val ){

The Code comes from php underscore. An error is reported in this area and it does not seem to support parameters.

function ($val) {

This method is used to write lambda functions (anonymous functions). It is often used in js and other scripting languages. However, this anonymous function has been supported since php 5.3. So the problem you encounter is that the php version is not enough. upgrade to the latest version of php 5.3.x to solve this problem.

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.