Home > Backend Development > PHP Tutorial > 类方法中使用array_地图报错- Cannot redeclare

类方法中使用array_地图报错- Cannot redeclare

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:39:45
Original
925 people have browsed it

类方法中使用array_map报错--- Cannot redeclare
方法定义如下:
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;
   }

   ......
}


调用过程如下(注:$mapper_1、$mapper_2是在同一次运行时调用方法):

$mapper_1=new mapper();
$mapper_2=new mapper();

var_dump($mapper_1->getProperties());  //正确返回
var_dump($mapper_2->getProperties());  //报错  Cannot redeclare getName()


截图如下:




Related labels:
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