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

WBOY
Release: 2016-06-13 10:09:10
Original
820 people have browsed it

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

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);
}

Related labels:
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!