Re: Can i run php script using command prompt in any location by typing scriptname.php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/7/2 Ravi Joshi <ravi.joshi53@xxxxxxxxx>:
> 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 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 script 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=phpfile
FTYPE phpfile=C:\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=ZEND002498&r=213474731
"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



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux