|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-06-08 16:38 UTC] hello at peterfeatherstone dot com
Description: ------------ In PHP 5.6 it seems that adding declare(ticks=1) and then using register_tick_function() would follow any includes and provide profiling information accordingly. In PHP 7+ however it now seems I have to add declare(ticks=1) in every file. I use this for profiling every method call on a page load and can't now add this to each PHP file in my system (If they are in libraries etc.). I can't find anything in the docs about changes that were made to this or an alternative method for profiling every tick in the application. Test script: --------------- Replication code can be found here - https://stackoverflow.com/questions/44440613/how-to-avoid-redeclaring-ticks-on-every-file-in-php-7?noredirect=1#comment75879747_44440613 Expected result: ---------------- Running php index.php I would expect to see 7 Actual result: -------------- In PHP 5.6 I see 7 as expected In PHP 7 I see 5 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
Replication code: index.php <?php declare(ticks=1); $count = 0; register_tick_function('ticker'); function ticker() { global $count; $count++; } $foo = 'foo'; $bar = 'bar'; include dirname(__FILE__) . '/inc.php'; echo $count; inc.php $baz = "baz"; $qux = "qux";