Page 1 of 1

comman line php

Posted: Fri Feb 09, 2007 11:14 am
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.

Posted: Fri Feb 09, 2007 11:54 am
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.

Posted: Fri Feb 09, 2007 12:39 pm
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.

Posted: Fri Feb 09, 2007 12:53 pm
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.

Posted: Fri Feb 09, 2007 1:04 pm
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:

Posted: Fri Feb 09, 2007 3:52 pm
by Ollie Saunders
The notes on command line PHP wrote:#!/usr/local/bin/php -q