How to Run a Batch File in PHP

Batch files (named for the BAT file extension) are plain text formatted files that execute on Windows computers. The PHP development language is used to create website applications, but the web page can execute a server batch file to complete application processes. This is beneficial if you want an internal application to execute when the user browses a web page. Execution of these files uses the PHP "Exec" function.

Instructions

    • 1

      Right-click your PHP file and select "Open With." Select "Notepad" from the list of applications and click "OK." This opens your PHP file in a plain text editor.

    • 2

      Type the following code into your PHP file:

      <? echo exec('executable.bat'); ?>

      The opening and closing characters next to the question marks indicate to your web host to execute the internal code instead of displaying it as HTML text. Replace the "executable.bat" file name with the name of your own batch file.

    • 3

      Click the "File" menu item at the top of the "Notepad" window. Click "Save" to save your PHP change.

Related Searches:

References

Resources

Comments

You May Also Like

Related Ads

Featured