Connecting Tech Pros Worldwide Forums | Help | Site Map

command-line PHP and suppressing headers - help

Phil Powell
Guest
 
Posts: n/a
#1: Jul 17 '05
How do I suppress the lines PHP normally delivers to stdout (your browser)
if I am doing command-line PHP?

e.g.

stuff.php:

<? echo 'Hello World'; ?>

Calling it from a Red Hat 7.3 command-line terminal I would do the
following:

php /my/directory/path/to/stuff.php

And I would eventually get

Hello World

But before that, an enormous amount of garbage, particularly HTTP header
information:

PHP Version 4.2.3
Content-type: text/html
Hello World

How do I strip everything out except that which I need to see while using
PHP from the command line? I am having a horrific time using TCL instead.

Thanx
Phil



Daniel Tryba
Guest
 
Posts: n/a
#2: Jul 17 '05

re: command-line PHP and suppressing headers - help


Phil Powell <soazine@erols.com> wrote:[color=blue]
> How do I suppress the lines PHP normally delivers to stdout (your browser)
> if I am doing command-line PHP?[/color]

$ php -h
Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-f <file> Parse <file>. Implies `-q'
-v Version number
-C Do not chdir to the script's directory
-c <path> Look for php.ini file in this directory
-a Run interactively
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-z <file> Load Zend extension <file>.
-l Syntax check only (lint)
-m Show compiled in modules
-i PHP information
-h This help

(or something really similar depending on php version (4.1.2 above))

--

Daniel Tryba

Anthony Borla
Guest
 
Posts: n/a
#3: Jul 17 '05

re: command-line PHP and suppressing headers - help



"Phil Powell" <soazine@erols.com> wrote in message
news:16oJb.62427$hf1.41608@lakeread06...[color=blue]
> How do I suppress the lines PHP normally delivers to stdout
> (your browser) if I am doing command-line PHP?
>
> e.g.
>
> stuff.php:
>
> <? echo 'Hello World'; ?>
>
> Calling it from a Red Hat 7.3 command-line terminal I would
> do the following:
>
> php /my/directory/path/to/stuff.php
>
> And I would eventually get
>
> Hello World
>
> But before that, an enormous amount of garbage, particularly
> HTTP header information:
>
> PHP Version 4.2.3
> Content-type: text/html
> Hello World
>[/color]

Your're using the CGI-version, rather than the CLI-version binary, from the
command-line.
[color=blue]
>
> How do I strip everything out except that which I need to see while using
> PHP from the command line? I am having a horrific time using TCL instead.
>[/color]

Relevant information may be obtained from:

http://php.net/manual/en/features.commandline.php

I hope this helps.

Anthony Borla


Phil Powell
Guest
 
Posts: n/a
#4: Jul 17 '05

re: command-line PHP and suppressing headers - help


Daniel Tryba <news_comp.lang.php@canopus.nl> wrote in message news:<bt5dpa$c60$2@news.tue.nl>...[color=blue]
> Phil Powell <soazine@erols.com> wrote:[color=green]
> > How do I suppress the lines PHP normally delivers to stdout (your browser)
> > if I am doing command-line PHP?[/color]
>
> $ php -h
> Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}
> -q Quiet-mode. Suppress HTTP Header output.
> -s Display colour syntax highlighted source.
> -f <file> Parse <file>. Implies `-q'
> -v Version number
> -C Do not chdir to the script's directory
> -c <path> Look for php.ini file in this directory
> -a Run interactively
> -d foo[=bar] Define INI entry foo with value 'bar'
> -e Generate extended information for debugger/profiler
> -z <file> Load Zend extension <file>.
> -l Syntax check only (lint)
> -m Show compiled in modules
> -i PHP information
> -h This help
>
> (or something really similar depending on php version (4.1.2 above))[/color]

php -q does the exact trick,thanx!

Phil
CountScubula
Guest
 
Posts: n/a
#5: Jul 17 '05

re: command-line PHP and suppressing headers - help


[color=blue]
> php -q does the exact trick,thanx!
>
> Phil[/color]

if you are heavy into cli, you can do this:

make the very first line of your script read:
#!/bin/php -q

then: (note: it does not have to end in .php)
chmod 755 yourscriptname

now your script is executable as a shell script.

put a copy of it in /usr/bin

then when ever you want to use it, just type the name of the script


--
Mike Bradley
http://gzen.myhq.info -- free online php tools


Phil Powell
Guest
 
Posts: n/a
#6: Jul 17 '05

re: command-line PHP and suppressing headers - help



"CountScubula" <me@scantek.hotmail.com> wrote in message
news:OdGJb.6186$Pb6.1414@newssvr25.news.prodigy.co m...[color=blue]
>[color=green]
> > php -q does the exact trick,thanx!
> >
> > Phil[/color]
>
> if you are heavy into cli, you can do this:
>
> make the very first line of your script read:
> #!/bin/php -q
>
> then: (note: it does not have to end in .php)
> chmod 755 yourscriptname
>
> now your script is executable as a shell script.
>
> put a copy of it in /usr/bin
>
> then when ever you want to use it, just type the name of the script
>
>
> --
> Mike Bradley
> http://gzen.myhq.info -- free online php tools
>
>[/color]

Thanx I'll have to remember that too!

Phil


Closed Thread