Overview
In PHP 5.6, it seems that adding declare(ticks=1)and then using register_tick_function()will follow any inclusions and provide relevant profiling information.
In PHP 7+, however now it seems to me that I should add declare(ticks=1)to each file. I use this to profile each method call when the page loads, and now I don’t want to add this to every PHP file on my system (some of them cannot be if they are in libraries).
I can not find anything in the docs about the changes that were made for this.
Replication steps
Create the following 2 files:
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
<?php
$baz = "baz";
$qux = "qux";
results
Running php index.phpin the terminal gives me:
declare(ticks=1) inc.php :
- , PHP 7 +?