I have a PHP script running permanently on a server. I have very limited access to restart it. Is there any way how to reset everything in the script from inside? I do not mean to physically stop and start the script.
I'm looking for a way how to almost restart it (unset()
all variables, un include all includes, "forgot" all functions) almost like a restart of the script.
The reason is to be able to "update" the script at least during the debugging phase. On a local host everything works as it supposed, but on a server there are some issues and for any change I have to call to a service desk). Lets say to make some changes in the include - then include it again, that means to initialize new functions, activate new variables....
I know that restart would be easier, nicer, crone would do the job, but unfortunately there is not the option... (Stupid situation, I know - but I can not change it, so looking for solution within my reach)
The idea is
<?
while (true) {
require(myInclude.php);
while (true){
// here is the code I need to process, it is in endless loop as it serves as a websocket server
doWhatIsNeeded(this_works_fine_no_need_to_adjust);
// condition that starts all the "cleaning"
if ($restartIsRequired == true){
break;
}
}
//unset all variables, un include all includes, "forget" all functions
// **************************************************************
// ****** here this is the part, I would like to help with ******
// ****** thank you :) ******
// **************************************************************
}