Run PHP script with parameters within another PHP script

Recently I had to call a PHP script within another script with some arguments. Normally you pass these parameters by GET or POST. But how to do it within another script? Here is how to run PHP script with parameters within another PHP script:

//set arguments 
$_SERVER['argv'][1] = '-action';
$_SERVER['argv'][2] = 'unsetMaintenanceMode';
$_SERVER['argv'][3] = '-initRedis';
$_SERVER['argv'][4] = '1';

//call script
unset($_SERVER['REQUEST_METHOD']);
include(dirname(dirname(__FILE__)) . '/mage/shell/utils/maintenanceModeToggle.php');

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.