对代码中行号的动态引用(Netbeans)


Dynamic reference to line number in the code (Netbeans)

在NetBeans中是否可以标记一行(例如PHP)代码并动态引用该行号?,像

echo "check the line number <tagged_line_number> in the script";

问题是,在代码开发中,任何一行都可以自然地更改一个数字,所以静态引用没有意义。

如果您正在寻找PHP解决方案,请使用LINE常量。

事实上弗拉迪斯拉夫的答案是正确的。你肯定可以像这样使用LINE常量:
$line = __LINE__ + 1; // use this right before the line you want to tag
// tagged line goes here
echo "the line number we refer to is $line";

输出将是:

the line number we refer to is 3

在浏览器中运行示例

但恐怕你的问题的答案是

在NetBeans中,是否可以标记一行代码并动态引用该行号?

是""。