how to run .php files in xampp in cmd

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • angela1
    New Member
    • Jan 2013
    • 1

    how to run .php files in xampp in cmd

    Sir/Mam How can i run any php files through xampp in cammand line prompt??Plzz help!!
    Last edited by angela1; Jan 21 '13, 04:16 PM. Reason: incomplete question
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You want to run PHP files through XAMPP, but in a CMD prompt window? That makes no sense.

    You can use the Program Execution Functions to execute commands from PHP, so if you wanted to run PHP files written for command line prompts from a website PHP file, you could try doing that with, say, the shell_exec function.
    Code:
    <?php
    // Create the command to execute the PHP file.
    // (Adjust the paths as needed!)
    $filePath = "/usr/bin/php /var/scripts/cmd_line_script.php";
    
    // Execute the command and capture the results.
    $result = shell_exec($command);
    
    // The result will be NULL if it failed, otherwise it'll be a string.
    if ($result) {
        echo "<pre>{$result}</pre>";
    }
    else {
        echo "<strong>Failed to execute PHP script.</strong>";
    }

    Comment

    Working...