How can i execute php program




















The easiest way is to install MAMP! Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to run php files on my computer Ask Question. Asked 9 years, 11 months ago. Active 11 months ago. Viewed k times. Improve this question. Abdulla Nilam Did you put the files in the htdocs directory of apache?

Do you want to run the script on a local Apache server on your computer? Or you prefer to run the script without a web server i. Is your computer a Windows or a Linux machine? Show 6 more comments. Active Oldest Votes. All your php files will have to be in this htdocs folder. When you save the file, name it test. Now open your favorite web browser like Firefox , Google Chrome etc.

Two things to note here: On the web, localhost means your own computer. So instead of test. This is test. Reading the manual is not the easiest way to begin your PHP learning process, but you'll always need this as a reference. Older comments. Leave a Reply Cancel reply Your email address will not be published. On Windows platforms, it's possible to associate php.

The special shebang first line for Unix does no harm on Windows as it's formatted as a PHP comment , so cross platform programs can be written by including it. A simple example of writing a command line PHP program is shown below. Example 2 Script intended to be run from command line script. The script above includes the Unix shebang first line to indicate that this file should be run by PHP.

The program first checks that there is the required one argument in addition to the script name, which is also counted. If not, or if the argument was --help , -help , -h or -? Otherwise, the argument is echoed out exactly as received. To run the above script on Unix, it must be made executable, and called simply as script.

On Windows, a batch file similar to the following can be created for this task:. Example 3 Batch file to run a command line PHP script script.

Assuming the above program is named script. See also the Readline extension documentation for more functions which can be used to enhance command line applications in PHP. When running under a network service certain operations will fail, because "No mapping between account names and security IDs was done". Submit a Pull Request Report a Bug. Example 1 Execute PHP script as shell script!



0コメント

  • 1000 / 1000