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 Richard Quadling <rquadling@xxxxxxxxxxxxxx>:
> 2009/7/2 Richard Quadling <rquadling@xxxxxxxxxxxxxx>:
>> 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
>>
>
> Microsoft Windows [Version 5.2.3790]
> (C) Copyright 1985-2003 Microsoft Corp.
>
> N:\>assoc .php=phpfile
> .php=phpfile
>
> N:\>ftype phpfile=C:\PHP5\PHP.EXE "%1" %*
> phpfile=C:\PHP5\PHP.EXE "%1" %*
>
> N:\>php
> 'php' is not recognized as an internal or external command,
> operable program or batch file.
>
> N:\>set path=%PATH%;C:\PHP5
>
> N:\>set PATHEXT=%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
> <?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=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
>

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.

-- 
-----
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