[PHP]commande line?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
cheikhbouchihda
Forum Commoner
Posts: 51
Joined: Thu Mar 02, 2006 2:08 pm
Location: France.

[PHP]commande line?

Post by cheikhbouchihda »

Hello,
I would like to know how to execute a PHP script in commande line, with linux.Thanks in advence for the answer.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

php -f filename.php
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

feyd wrote:

Code: Select all

php -f filename.php
If PHP is not in your PATH variable it's possible the binary sits somewhere like /usr/lib/php/bin/ or such like ;)
cheikhbouchihda
Forum Commoner
Posts: 51
Joined: Thu Mar 02, 2006 2:08 pm
Location: France.

Post by cheikhbouchihda »

Thank you very much :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I've found that "which php" can do miracles ;)

Usually i use /usr/bin/env as shebang in my shell scripts... Eg:

Code: Select all

#!/usr/bin/env php
<?php .... ?>

Code: Select all

#!/usr/bin/env perl
print "hello";


...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"And shebangs, shebangs
Oh baby
When she moves, she moves
I go crazy..."

:lol: couldn't help myself today.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

feyd wrote:"And shebangs, shebangs
Oh baby
When she moves, she moves
I go crazy..."

:lol: couldn't help myself today.
8O Oh dear....
Post Reply