Use Array_ map in class method error-Cannot redeclare

Source: Internet
Author: User
Use Array_map error in class method---cannot redeclare
The method is defined as follows:
Class maaper{
......
Public Function getProperties () {
function GetName ($reflectionProperties) {
return $reflectionProperties->name;
}
$domain = $this->get_domain ();
$reflectionProperties = $domain->getproperties (reflectionproperty::is_public);
$properties =array_map (' GetName ', $reflectionProperties);
return $properties;
}

......
}


The invocation process is as follows (note: $mapper _1, $mapper _2 is called at the same runtime):

$mapper _1=new mapper ();
$mapper _2=new mapper ();

Var_dump ($mapper _1->getproperties ()); return correctly
Var_dump ($mapper _2->getproperties ()); Error cannot redeclare getName ()


As follows:




Share to:


------Solution--------------------
function GetName ($reflectionProperties) {
return $reflectionProperties->name;
}
Define global functions wherever you are
  • 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.