PHP使用声明? a是什么? [英] PHP using Declare ? What is a tick?
问题描述
我对PHP函数declare
有点困惑.
I am a little bit confused by the PHP function declare
.
一个勾到底是什么?我以为一个勾号等于一行代码?
What exactly is a single tick? I thought a tick equals one line of code?
但是如果我使用:
function myfunc() {
print "Tick";
}
register_tick_function("myfunc");
declare(ticks=1) {
echo 'foo!bar';
}
脚本打印:
滴答" 2次?
推荐答案
您会在每一行中打勾;和每个区块{} 尝试:
You get a tick for each line ; and each block {} Try that:
declare(ticks=1) echo 'foo!bar';
没有障碍,没有多余的勾号.
No block, no extra tick.
declare(ticks=1) {{ echo 'foo!bar'; }}
更多无关的块=更多的滴答声.
More extraneous blocks = more ticks.
PS:顺便说一句,tick是相当奇特的功能,它们仅在某些极其稀有情况下有用.它们不等同于线程或其他任何东西.如果对您来说,滴答声是解决问题的方法,那么您应该在另一个问题中发布有关您问题的信息,因为这可能不是解决问题的正确方法.
PS: by the way, ticks are quite the exotic feature and they're only useful in a few extremely rare situations. They are not equivalent to threading or anything. If, for you, ticks are the solution to a problem then you should post about your problem in another question because it's probably not the right solution to it.
这篇关于PHP使用声明? a是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!