comman line php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
murlopaz
Forum Commoner
Posts: 60
Joined: Wed Oct 11, 2006 5:02 pm
Location: Baltimore, MD, USA

comman line php

Post by murlopaz »

Hi everybody. I am working on a script that needs to be run from the command line.
I want the script not to ouput html headers, so i am using the -q option.
I also want to output some to the command line window.
Because I am using the -q parameter, nothing is going to be output from echo statements.

Any help will be much appreciated.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I can't find an option -q at http://www.php.net/manual/en/features.commandline.php
And I can't find a difference in the output of

Code: Select all

php -q -r "echo php_sapi_name();"
and

Code: Select all

php -r "echo php_sapi_name();"
both times it's cli without any http headers.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

the -q is a deprecated flag. I don't believe you need it any more. Just take off the -q & you should be fine.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
murlopaz
Forum Commoner
Posts: 60
Joined: Wed Oct 11, 2006 5:02 pm
Location: Baltimore, MD, USA

Post by murlopaz »

everything works fine with -q actually...
without -q i would get

Content-type: text/html
X-Powered-By: PHP/4.3.9

and then everything esle.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Have you tried it? I've got old scripts with the -q & I can output using echo() just fine.

Have you tried running PHP without the -q flag? I don't want to split hairs, but you did say 'would get' rather than 'did get' :wink:
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

The notes on command line PHP wrote:#!/usr/local/bin/php -q
Post Reply