command-line PHP and suppressing headers - help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    command-line PHP and suppressing headers - help

    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

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

    Comment

    • Anthony Borla

      #3
      Re: command-line PHP and suppressing headers - help


      "Phil Powell" <soazine@erols. com> wrote in message
      news:16oJb.6242 7$hf1.41608@lak eread06...[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:



      I hope this helps.

      Anthony Borla


      Comment

      • Phil Powell

        #4
        Re: command-line PHP and suppressing headers - help

        Daniel Tryba <news_comp.lang .php@canopus.nl > wrote in message news:<bt5dpa$c6 0$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

        Comment

        • CountScubula

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


          Comment

          • Phil Powell

            #6
            Re: command-line PHP and suppressing headers - help


            "CountScubu la" <me@scantek.hot mail.com> wrote in message
            news:OdGJb.6186 $Pb6.1414@newss vr25.news.prodi gy.com...[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


            Comment

            Working...