Can i run php script using command prompt in any location by typing scriptname.php
Can i run php script using command prompt in any location by typing scriptname.php
am 02.07.2009 17:33:44 von Ravi Joshi
--0-1043735027-1246548824=:26032
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,
=A0 =A0 I have downloaded ZendServer-CE-4.0.3-Windows_x86.exe(49.6 M=
B) and installed it in C:\Program Files\Zend derectory .Whenever i want to =
run any php script i have to put my php script in C:\Program Files\Zend\Zen=
dServer\bin directory and then by the command prompt first i goto in C:\Pro=
gram Files\Zend\ZendServer\bin location and then i type php scriptname.php.=
after doing this i get the output from php script.
=A0 I want to ask that can i run my php script by simply double=
clicking or by command prompt only by typing scriptname.php in any locatio=
n.
-Ravi Joshi
=0A
--0-1043735027-1246548824=:26032--
Re: Can i run php script using command prompt in any
am 02.07.2009 17:43:22 von Richard Quadling
2009/7/2 Ravi Joshi :
> Hi,
> Â Â Â Â I have downloaded ZendServer-CE-4.0.3-Windows_=
x86.exe(49.6 MB) and installed it in C:\Program Files\Zend derectory .Whene=
ver i want to run any php script i have to put my php script in C:\Program =
Files\Zend\ZendServer\bin directory and then by the command prompt first i =
goto in C:\Program Files\Zend\ZendServer\bin location and then i type php s=
criptname.php. after doing this i get the output from php script.
> Â Â Â Â Â I want to ask that can i run my php script=
by simply double clicking or by command prompt only by typing scriptname.p=
hp in any location.
> -Ravi Joshi
>
>
>
Yes you can. It's quite easy.
It involves a few things ...
1 - Add the location of php.exe to the path.
This is normally done by going to the Control Panel -> System ->
Advanced -> Environment Variables.
You can either add it just for you (User variables for xxxx) or
globally (System variables).
If there is no PATH, then add it. If there is a PATH then edit it and
add the location at the end with a ; in front ...
Existing Locations;C:\PHP5
(for example).
2 - Tell Windows that .php files are handled by PHP.EXE
At the command line type ...
ASSOC .php=3Dphpfile
FTYPE phpfile=3DC:\PHP5\PHP.EXE "%1" %*
3 - Allow PHP files to be auto-executable.
Another environment variable to alter. This time it is PATHEXT. If you
want .PHP to be handled before .BAT then place .PHP before the .BAT.
If not put it at the end.
That should do the trick.
--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Can i run php script using command prompt in any
am 02.07.2009 17:47:21 von Richard Quadling
2009/7/2 Richard Quadling :
> 2009/7/2 Ravi Joshi :
>> Hi,
>> Â Â Â Â I have downloaded ZendServer-CE-4.0.3-Windows=
_x86.exe(49.6 MB) and installed it in C:\Program Files\Zend derectory .When=
ever i want to run any php script i have to put my php script in C:\Program=
Files\Zend\ZendServer\bin directory and then by the command prompt first i=
goto in C:\Program Files\Zend\ZendServer\bin location and then i type php =
scriptname.php. after doing this i get the output from php script.
>> Â Â Â Â Â I want to ask that can i run my php scrip=
t by simply double clicking or by command prompt only by typing scriptname.=
php in any location.
>> -Ravi Joshi
>>
>>
>>
>
> Yes you can. It's quite easy.
>
> It involves a few things ...
>
> 1 - Add the location of php.exe to the path.
>
> This is normally done by going to the Control Panel -> System ->
> Advanced -> Environment Variables.
>
> You can either add it just for you (User variables for xxxx) or
> globally (System variables).
>
> If there is no PATH, then add it. If there is a PATH then edit it and
> add the location at the end with a ; in front ...
>
> Existing Locations;C:\PHP5
>
> (for example).
>
> 2 - Tell Windows that .php files are handled by PHP.EXE
>
> At the command line type ...
>
> ASSOC .php=3Dphpfile
> FTYPE phpfile=3DC:\PHP5\PHP.EXE "%1" %*
>
> 3 - Allow PHP files to be auto-executable.
>
> Another environment variable to alter. This time it is PATHEXT. If you
> want .PHP to be handled before .BAT then place .PHP before the .BAT.
> If not put it at the end.
>
> That should do the trick.
>
>
> --
> -----
> Richard Quadling
> Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D2134=
74731
> "Standing on the shoulders of some very clever giants!"
> I need a car : http://snipurl.com/l4pih
> ZOPA : http://uk.zopa.com/member/RQuadling
>
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
N:\>assoc .php=3Dphpfile
..php=3Dphpfile
N:\>ftype phpfile=3DC:\PHP5\PHP.EXE "%1" %*
phpfile=3DC:\PHP5\PHP.EXE "%1" %*
N:\>php
'php' is not recognized as an internal or external command,
operable program or batch file.
N:\>set path=3D%PATH%;C:\PHP5
N:\>set PATHEXT=3D%PATHEXT%;.PHP
N:\>php -v
PHP 5.3.1-dev (cli) (built: Jul 2 2009 10:58:12)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
N:\>copy con doit.php
echo PHP_VERSION;
^Z
1 file(s) copied.
N:\>doit
5.3.1-dev
N:\>
--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Can i run php script using command prompt in any
am 02.07.2009 17:48:50 von Richard Quadling
2009/7/2 Richard Quadling :
> 2009/7/2 Richard Quadling :
>> 2009/7/2 Ravi Joshi :
>>> Hi,
>>> Â Â Â Â I have downloaded ZendServer-CE-4.0.3-Window=
s_x86.exe(49.6 MB) and installed it in C:\Program Files\Zend derectory .Whe=
never i want to run any php script i have to put my php script in C:\Progra=
m Files\Zend\ZendServer\bin directory and then by the command prompt first =
i goto in C:\Program Files\Zend\ZendServer\bin location and then i type php=
scriptname.php. after doing this i get the output from php script.
>>> Â Â Â Â Â I want to ask that can i run my php scri=
pt by simply double clicking or by command prompt only by typing scriptname=
..php in any location.
>>> -Ravi Joshi
>>>
>>>
>>>
>>
>> Yes you can. It's quite easy.
>>
>> It involves a few things ...
>>
>> 1 - Add the location of php.exe to the path.
>>
>> This is normally done by going to the Control Panel -> System ->
>> Advanced -> Environment Variables.
>>
>> You can either add it just for you (User variables for xxxx) or
>> globally (System variables).
>>
>> If there is no PATH, then add it. If there is a PATH then edit it and
>> add the location at the end with a ; in front ...
>>
>> Existing Locations;C:\PHP5
>>
>> (for example).
>>
>> 2 - Tell Windows that .php files are handled by PHP.EXE
>>
>> At the command line type ...
>>
>> ASSOC .php=3Dphpfile
>> FTYPE phpfile=3DC:\PHP5\PHP.EXE "%1" %*
>>
>> 3 - Allow PHP files to be auto-executable.
>>
>> Another environment variable to alter. This time it is PATHEXT. If you
>> want .PHP to be handled before .BAT then place .PHP before the .BAT.
>> If not put it at the end.
>>
>> That should do the trick.
>>
>>
>> --
>> -----
>> Richard Quadling
>> Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213=
474731
>> "Standing on the shoulders of some very clever giants!"
>> I need a car : http://snipurl.com/l4pih
>> ZOPA : http://uk.zopa.com/member/RQuadling
>>
>
> Microsoft Windows [Version 5.2.3790]
> (C) Copyright 1985-2003 Microsoft Corp.
>
> N:\>assoc .php=3Dphpfile
> .php=3Dphpfile
>
> N:\>ftype phpfile=3DC:\PHP5\PHP.EXE "%1" %*
> phpfile=3DC:\PHP5\PHP.EXE "%1" %*
>
> N:\>php
> 'php' is not recognized as an internal or external command,
> operable program or batch file.
>
> N:\>set path=3D%PATH%;C:\PHP5
>
> N:\>set PATHEXT=3D%PATHEXT%;.PHP
>
> N:\>php -v
> PHP 5.3.1-dev (cli) (built: Jul  2 2009 10:58:12)
> Copyright (c) 1997-2009 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
>
> N:\>copy con doit.php
>
> echo PHP_VERSION;
> ^Z
> Â Â Â Â 1 file(s) copied.
>
> N:\>doit
> 5.3.1-dev
> N:\>
>
> --
> -----
> Richard Quadling
> Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D2134=
74731
> "Standing on the shoulders of some very clever giants!"
> I need a car : http://snipurl.com/l4pih
> ZOPA : http://uk.zopa.com/member/RQuadling
>
Remember that if you double click a PHP script and it runs, it will
close when it has finished. If you are expecting to see the output on
screen, you'll have to be quick.
php-win.exe is also available. This will not show any results - useful
for scheduled tasks.
Regards,
Richard.
--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Can i run php script using command prompt in any
am 04.07.2009 18:53:18 von phpWalter
Quoting Ravi Joshi :
> Hi,
> =A0 =A0 I have downloaded ZendServer-CE-4.0.3-Windows_x86.exe(49.6 =
=20
> MB) and installed it in C:\Program Files\Zend derectory .Whenever i =20
> want to run any php script i have to put my php script in C:\Program =20
> Files\Zend\ZendServer\bin directory and then by the command prompt =20
> first i goto in C:\Program Files\Zend\ZendServer\bin location and =20
> then i type php scriptname.php. after doing this i get the output =20
> from php script.
> =A0 I want to ask that can i run my php script by simply doubl=
e =20
> clicking or by command prompt only by typing scriptname.php in any =20
> location.
Yes and no.
No, you can't double click it.
Yes, you can if you set up the proper association with the .php extension.
No, you can't just type the scriptname.php at the command line to run =20
the script.
Yes, if you have the path to PHP executable in your PATH variable, =20
then you can type...
> php scriptname.php
Walter--
....that's the thing about people who think they hate computers.
What they really hate is lousy programmers.
- Larry Niven and Jerry Pournelle in "Oath of Fealty"
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Can i run php script using command prompt in any
am 04.07.2009 23:27:52 von Richard Quadling
2009/7/4 Walter Torres :
> Quoting Ravi Joshi :
>
>> Hi,
>> Â Â Â Â I have downloaded ZendServer-CE-4.0.3-Windows=
_x86.exe(49.6 Â MB) and
>> installed it in C:\Program Files\Zend derectory .Whenever i  want t=
o run any
>> php script i have to put my php script in C:\Program
>> Â Files\Zend\ZendServer\bin directory and then by the command prompt=
 first i
>> goto in C:\Program Files\Zend\ZendServer\bin location and  then i t=
ype php
>> scriptname.php. after doing this i get the output  from php script.
>> Â Â Â Â Â I want to ask that can i run my php scrip=
t by simply double
>> Â clicking or by command prompt only by typing scriptname.php in any
>> Â location.
>
> Yes and no.
>
> No, you can't double click it.
> Yes, you can if you set up the proper association with the .php extension=
..
>
> No, you can't just type the scriptname.php at the command line to run the
> script.
> Yes, if you have the path to PHP executable in your PATH variable, then y=
ou
> can type...
>
> Â > php scriptname.php
>
> Walter--
> ...that's the thing about people who think they hate computers.
> What they really hate is lousy programmers.
> Â - Larry Niven and Jerry Pournelle in "Oath of Fealty"
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Walter.
You CAN just double click a PHP script and have it run. Just like you
can double click a BAT and have it run.
You CAN just type the name of a PHP script at the command line
(without the .php extension and without having to type the name of the
executable) and have it run. Just like you can type the name of a BAT
script (without the .bat extension and without having to enter the
name of the executable) and have it run.
In fact, you can have ANY sort of file automatically processed (not
executed, though that is the primary intent of the mechanism that
supports this facility).
The environment variable PATHEXT is the key. [1] and [2] have relevant
information.
Once you've told the OS that a PHP script is to be considered
executable, it is just a case of joining the extension to an
executable. In this case the php-cli.exe for PHP4 and php.exe for
PHP5. Add the location of the executable to the PATH to make things
easier and you're done.
If this setting up process takes more than 2 minutes, then you're
doing it wrong.
No need to reboot, but any open command prompts would need to be
cycled to gain the new environment variable settings.
Regards,
Richard.
[1] http://wiki.tcl.tk/1785
[2] http://en.wikipedia.org/wiki/COM_file#Execution_preference
--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Can i run php script using command prompt in any
am 05.07.2009 06:14:39 von phpWalter
> Walter.
>
> You CAN just double click a PHP script and have it run. Just like you
> can double click a BAT and have it run.
Welp! I'm Wrong again!
Walter
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php