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/4 Walter Torres <phpwalter@xxxxxxxxx>:
> Quoting 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.
>
> 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 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
>
>

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

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