In my current project, I found myself facing a time exceeding issue,the program was taking nearly 13 minutes to generate a report which was very unusual because the page didn’ t have any complex queries or loop to iterate. As i am working in an accounting project, it seems to be a strange problem to us. Because we have the same base class used in other two files which generate reports perfectly. So we set about to unravel the mystery but it is hard to debug a pre built framework. In such situations, we generally use die(), exit(), print(), print_r() or echo. These are usual functions to work on. Apart from these all, PHP provides a built in function which helps us to call a function whenever a script finishes its execution. It is register_shutdown_function(). The syntax is void register_shutdown_function(function_to_be_called,args list)
|
This is mainly used to know whether the particular fucntion is executed successfully or not. And while you use this function one can identify till which section the code is executed. But it has some points to be taken care off Overall, Its really a nice function, infact its a perfect debugger where a developer can debug any code whether it may be his project or any pre built framework. I hope this helps PHP beginners who might not be aware of this approach.
|