gpt4 book ai didi

php - 获取函数声明开始的文件名和行号

转载 作者:可可西里 更新时间:2023-11-01 00:01:06 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to find out where a function is defined?
included php file to know it's file name?

我可以在 PHP 中获取函数声明开头的文件名行号吗?

比如说,我有以下代码:

 1. /**
2. * This function shows the foo bar.
3. */
4. function foo_bar($subject) {
5. echo "Foo bar:\n";
6. if ($subject == "none") {
7. trigger_error("Wrong argument given to 'foo_bar()' in ... on line ....", E_USER_WARNING);
8. }
9. ...
10. }

当我调用 foo_bar("none") 时,该函数必须抛出如下错误:

Warning: Wrong argument given to 'foo_bar()' in /home/web/mcemperor on line 4.

我可以检索函数声明开始的文件名行号吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com