|
| |||||||||
| Tags: c program, cgi, cli, command line, dos prompt, html tags, java, php, web applications |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| Can we use PHP from the command line?
I am not having much knowledge about the PHP. I have done with the basic programs in PHP but when it comes to somewhat advanced I am rookie. I have never used the command line for the PHP. One thing that always comes in my mind is can we use PHP from the command line?. And also please tell me what does it contains.?? Help me as soon as possible..!! ![]()
__________________ "When they give you ruled paper, write the other way..." J.R.J. |
|
#2
| ||||
| ||||
| Re: Can we use PHP from the command line?
According to me for developing the web applications rapidly and economically, PHP is a great language. Script like c, c++, java, etc the PHP can also be run as a command line. There are many other tasks that need to be run on the background in the web server, other than the building web applications and websites which takes lot of time. You can create command line PHP script as we do for web script. You can use the command Code: php -h |
|
#3
| |||
| |||
| Re: Can we use PHP from the command line?
The SAPI is supported by the PHP. The main focus of this SAPI is for developing shell applications with PHP. Typing php -v, in the shell application will let you know whether php you are using is CGI or CLI. In a command line scripting, you cannot use any kind of HTML tags. The reason behind this is that the output is displaying in the DOS prompt and not in the web browser. You cannot use the <BR> tag for inserting new line in the command line scripting instead of that you will have to use the \n to output the new line. Hope that you are clear with the concepts of the command line which is being used in PHP. |
|
#4
| ||||
| ||||
| Re: Can we use PHP from the command line?
You can understand more better if you look at the examples below. I have given a small command line script to output “Hello World”. The following is the code for that : PHP Code: Now if you want to execute the above script in command prompt or the shell prompt, you will have to type the following command : Code: php helloworld.php
__________________ Signatures reduce available bandwidth |
|
#5
| ||||
| ||||
| Re: Can we use PHP from the command line?
If you want to run a phpfile directly, the only thing you will have to type the command php filename.php. This is the simplest use of PHP command line mode. You will have to make some changes in your setups in to your running environment, which should be done otherwise there will be some errors. The following are the list of the changes that should be done :
__________________ Grand Theft Auto 4 PC Video Game |
|
#6
| ||||
| ||||
| Re: Can we use PHP from the command line?
I am going little deep, which can help you in future. You can use the standard output stream defined in CLI version of the PHP, instead of using print or echo for output that we normally use. There are three IO streams in PHP, which are described as follows :
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Can we use PHP from the command line?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| WMP Command Line | Ittai | Media Player | 2 | 12-05-2010 04:31 AM |
| xcopy command line together with wmplayer command line | Aislinn | Operating Systems | 5 | 31-03-2010 01:13 PM |
| PROBLEM: COMMAND LINE OPTION SYNTAX ERROR. TYPE COMMAND /? FOR HEL | FORTHELOVEOFGODPLEASEHELPME | MediaCenter | 3 | 03-09-2009 06:41 PM |
| Command Line Ren (Rename) command broken? | SixSigmaGuy | Vista Help | 2 | 18-05-2008 04:30 PM |
| autorun.inf - shell\..\command with command line parameter doesn'twork | kakii | Windows XP Support | 1 | 18-05-2007 02:24 AM |