php 函数被调用位置,php:确定调用函数的位置

Mariusz Char..

17

我发现最快最简单的解决方案

public function func() { //function whose call file you want to find

$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);

}

$trace: Array

(

[0] => Array

(

[file] => C:\wamp\www\index.php

[line] => 56

[function] => func

[class] => (func Class namespace)

[type] => ->

)

)

我在联想笔记本电脑上测试速度:Intel Pentiom CPU N3530 2.16GHz,RAM 8GB

global $times;

$start = microtime(true);

$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);

$times[] = microtime(true) - $start;

结果:

count($times): 97

min: 2.6941299438477E-5

max: 10.68115234375E-5

avg: 3.3095939872191E-5

median: 3.0517578125E-5

sum: 321.03061676025E-5

the same results with notation without E-5

count($times): 97

min: 0.000026941299438477

max: 0.0001068115234375

avg: 0.000033095939872191

median: 0.000030517578125

sum: 0.0032103061676025

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值