Home  >  Article  >  Backend Development  >  这两天碰到几个面试题求解决解决办法

这两天碰到几个面试题求解决解决办法

WBOY
WBOYOriginal
2016-06-13 10:09:10820browse

这两天碰到几个面试题求解决

1.要求自己写出一个var_dump函数出来。
有点不解的是怎么实现对象输出,求解?
2.要求使用heredoc实现echo的功能。


------解决方案--------------------
class a
{
public $test="a";
public function test()
{
return "test。。";
}
}

$b=new a();
$array=get_object_vars($b);
foreach ($array as $value){
echo $value.'类型:'.gettype($value);
}

Statement:
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