how do I execute an .php file?

1

I have a page in php and I would like to run another code in php more I can not get someone can tell me what I am doing wrong:

if ($_GET["URL"] === 'WEEK' || $_GET["URL"] === 'week'){
    $obj = new COM("WScript.Shell");

    if (is_object($obj)){
        $obj->Run ("week.php");
    }else{
        echo "Não foi possível criar o objeto!";
    }

}
    
asked by anonymous 12.05.2016 / 13:29

1 answer

1

You can run a command for the operating system using phrases together with the console command :

$retorno = 'php -f week.php';

See an example on Ideone .

It's important to note that setting safe_mode is disabled .

But this approach you are taking is insecure !!

As you will ensure that the code that will be executed has not been modified, is it malicious? There are other ways to solve the problem. If you call a PHP file from the console inside PHP, there is something wrong.

    
12.05.2016 / 14:17