How can i execute php




















Help Center. For Linux Hosting Although the PHP scripting language has been mainly developed for the creation of dynamic websites, you can also execute PHP scripts completely independent of the web server. A device with an SSH client installed. For computers with Windows operating system we recommend the program Putty. How to run php files on my computer Ask Question.

Asked 9 years, 10 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. Improve this answer.

Add a comment. Pacerier Bhaxy Bhaxy 5, 10 10 gold badges 36 36 silver badges 40 40 bronze badges. SlavaNov SlavaNov 2, 1 1 gold badge 17 17 silver badges 26 26 bronze badges. The first index zero always contains the name of the script as called from the command line. As long as the arguments to be passed to the script do not start with the - character, there's nothing special to watch out for.

Passing an argument to the script which starts with a - will cause trouble because the PHP interpreter thinks it has to handle it itself, even before executing the script.

To prevent this, use the argument list separator After this separator has been parsed by PHP, every following argument is passed untouched to the script. However, on Unix systems there's another way of using PHP for shell scripting: make the first line of the script start with!

Once the execution attributes of the file are set appropriately e. Assuming this file is named test in the current directory, it is now possible to do the following:. As can be seen, in this case no special care needs to be taken when passing parameters starting with -.

On Unix systems, the special! 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.



0コメント

  • 1000 / 1000