0

Say I start a PHP script via command line.

Is there a way that PHP can restart/rerun the script from the top via a command inside the PHP script?

<?php
if($something == 'yes')
{
 // restart/rerun whole PHP script
}
?>
Mr.Boon
  • 2,024
  • 7
  • 35
  • 48

1 Answers1

0

As told in comment you can send header. or if you in the middle of page, you can add <script> tag with window.location.reload() there

DuhVir
  • 447
  • 1
  • 4
  • 15
  • Hi, this is a PHP only script, no HTML/JS. Only runs via cron in commandline – Mr.Boon Sep 25 '19 at 12:14
  • Then advice of @Mr.Boon. Script with variable `needReload = false` then all script in function. In case of success do nothing. If you need reload then `needReload = true` and return. In main script call function again in loop if `true`. But beware of endless cycle. – DuhVir Sep 25 '19 at 12:29