PHP Declare kullanıyor?

3 Cevap php

Php function declare tarafından karıştı biraz iam.

What exactly is an single tick, i thought 1 tick = one line of code? But if i use:

function myfunc() {
        print "Tick";   
}

register_tick_function("myfunc");

declare(ticks=1) {
   echo 'foo!bar';
}

Komut dosyası yazdırır:

2 kere "Kene"?

3 Cevap

You get a tick for each line ; and each block {} Try that:

declare(ticks=1) echo 'foo!bar';

Hayır blok, hiçbir ekstra kene.

declare(ticks=1) {{ echo 'foo!bar'; }}

Daha fazla yabancı bloklar = daha fazla keneler.

PS: Bu arada, keneler oldukça egzotik bir özelliktir ve birkaç extremely rare durumlarda sadece faydalıdır. Onlar parçacığı ya da bir şey ile eşdeğer değildir. Sizin için, kene bir soruna çözüm, eğer muhtemelen ona doğru çözüm değil, çünkü o zaman başka bir soru sorun hakkında gönderilmesi gerekiyor.

Bir kene ne olduğu doğru yolda.

http://www.tuxradar.com/practicalphp/4/21/0

Put simply, a tick is a special event that occurs internally in PHP each time it has executed a certain number of statements. These statements are internal to PHP and loosely correspond to the statements in your script. You can control how many statements it takes to set off a tick using the declare() function, and you can register functions to execute when a tick occurs by using the register_tick_function() function. As mentioned already, the syntax for declare is very unusual, so be ready for a shock!

PHP6 keneler tamamen silinecektir unutmayın.

In simply declare is a construct used in conjunction with ticks and register_tick_function and the usage of declare and ticks were clearly explained in the below link

http://phpadvocate.com/blog/2010/01/using-declare-and-ticks-with-php/ burada takip edebilirsiniz ...

Onun için teşekkürler benim için değil ;)