How do I run a.php file?

Asked

Viewed 302 times

1

I have a page on php and would like to run another code on php but I’m not getting anyone can tell me what I’m 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!";
    }

}

1 answer

1

You can execute a command for the operating system using crases together with the console command:

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

See an example on Ideone.

It is important to note whether the configuration safe_mode is disabled.

But this approach you are taking is insecure!!

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

  • didn’t work that mess of yours

  • @Chapolin works yes https://ideone.com/iPznB3 Check your PHP configuration, specifically safe_mode http://php.net/manual/en/language.operators.execution.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.