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