很简单的功能,用到PHP中的反射机制,具体使用的是ReflectionFunction
类,可以获取指定函数所在PHP脚本中的具体位置。 创建引用脚本。
代码:
- // Filename: functions.php
- <?php
- function now() {
- return time();
- }
- ?>
调用:
- // Filename: call_now.php
- <?php
- require 'functions.php';
- Reflection::export(new ReflectionFunction('now'));
- // Function [ function now ] { @@ H:\www\functions.php 2 - 4 }
- ?>