<?php

 /**
* reference:http://www.php.net/manual/en/reflectionmethod.getclosure.php
* Learn this and you will know How to peer through what a horse is thinking!
*
* Class Client
*/
class People
{
private $heartWords = "How beautiful the horse is!I want to ride it!"; public function hook()
{
$who = get_class($this);
echo ucfirst($who). " says :".$this->heartWords. "\n";
} public function peer()
{
return function(){
$this->hook();
};
}
} class Horse
{
private $heartWords = "How silly the guy is! A big ass!";
} $people = new People();
$horse = new Horse(); try{
$reflection = new ReflectionClass(get_class($people));
}
catch(ReflectionException $e)
{
echo $e->getMessage() ."\n";
return;
} $closure = $reflection->getMethod('hook')->getClosure($people);
$truth = $closure->bindTo($horse,$horse); $truth(); // Horse says :How silly the guy is! A big ass!

最新文章

  1. 仿喜马拉雅实现ListView添加头布局和脚布局
  2. Best Coder Round#25 1003 树的非递归访问
  3. xCode删除storyboard,新建window并启动
  4. python中的namespace
  5. css居中的几种方式
  6. javascript-实现日期大写
  7. 关于 Java 性能监控您不知道的 5 件事,第 1 部分
  8. Callgrind 使用 2
  9. 标准I/O的替代软件
  10. Python之路【第一篇】:Python前世今生
  11. .NET 中使用 HttpWebResponse 时 Cookie 的读取
  12. 手工删除crfclust.bdb文件
  13. 微信小程序入门指南
  14. sql执行内部操作期间检测到不一致性解决方案
  15. MySQL数据库(一)
  16. SpringBoot 基础01
  17. Qt QLineEdit
  18. 【Tomcat】tomcat内存配置登记册
  19. Ubuntu安装软件提示boot空间不足
  20. 详细解读Volley(一)—— 基本Request对象 &amp; RequestQueue

热门文章

  1. mysql中查询字段为null或者不为null的sql语句怎么写?
  2. (六十八)c#Winform自定义控件-DEMO整理
  3. Redis在新项目中的使用场景
  4. springboot postman 对象里传时间格式问题
  5. 学习数据库SQL语句1
  6. 全方位深度剖析PHP7底层源码(已完结)
  7. Uva 232 一个换行WA 了四次
  8. 初入计算机专业,学习c语言的第一周作业问答
  9. [LeetCode]sum合集
  10. selenium介绍及环境安装