Question

I'm not sure if it's present in PHP or not, or you might think of it a crazy or a wild idea. But somehow, it would be very convenient for me if I can make a function to execute after each statement in a PHP script.

For example:-

Normal Case:-

<?php

$a = 1;
$b = 2;
echo $a . "\n";
echo $b . "\n";

?>

This should result in:-

1
2

I want a case where I can write a function:-

function should_excute_after_each_php_statement() {
   echo 'a statement completed' . "\n";
}

and the script should result:-

a statement completed
a statement completed
1
a statement completed
2
a statement completed

Possible?

Was it helpful?

Solution

From what I understand from your question I'd say phps "ticks" are exactly what you are looking for:. They usually come in handy for debugging purposes. Give 'em a look!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top