PHP5 - CLI ("php -a") help plse?

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

    PHP5 - CLI ("php -a") help plse?

    Hi

    I've "upgraded" to PHP5 on my windoze box and whilst I'm stumbling up
    the learning curve quite happily, I'm a bit stuck at how to use the
    php.exe CLI binary.

    I've tried using "php -a" and other than sucking in everything I type
    until I get bored and Ctrl-C it, I can't get it to do anything useful.

    What I hope it will do is accept input from me and return the results -
    am I on the right track or have I missed the point somewhere?

    I have searched the 'net and the docm. but can't find anything relevant
    - so if someone can get me going I'd be very appreciative. Funnily
    enough, I have no problems at all in embedding (OK, so it's only
    simple) PHP in my HTML, running it all thru my Abyss local webserver
    and seeing my pages. I just want to be able to do CLI PHP'ing to test
    out snippets...

    Any help gratefully received.

    Cheers and Happy New Year

    Bill

  • zeltus

    #2
    Re: PHP5 - CLI ("php -a") help plse?

    Ahh, I found a reference at phpkitchen... it seems I have to use <? or
    mebee <?php to get php -a into interactive mode, and then use Ctrl-Z to
    force execution whenever I need it.

    Dunno why I need this tho' - what "mode" is it in if it isn't
    implicitly <?php... ????

    Bill

    Comment

    • Jerry Stuckle

      #3
      Re: PHP5 - CLI (&quot;php -a&quot;) help plse?

      zeltus wrote:[color=blue]
      > Ahh, I found a reference at phpkitchen... it seems I have to use <? or
      > mebee <?php to get php -a into interactive mode, and then use Ctrl-Z to
      > force execution whenever I need it.
      >
      > Dunno why I need this tho' - what "mode" is it in if it isn't
      > implicitly <?php... ????
      >
      > Bill
      >[/color]

      That's because php reads a file. If you give it a file name, it uses
      that file. If not, it reads the file from stdin (the command line).

      In the latter case, Ctrl-Z indicates the end of the file, so PHP can
      then process the entire file.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Pedro Graca

        #4
        Re: PHP5 - CLI (&quot;php -a&quot;) help plse?

        zeltus wrote:[color=blue]
        > I've tried using "php -a" and [...] I can't get it to do anything useful.
        >
        > What I hope it will do is accept input from me and return the results -
        > am I on the right track or have I missed the point somewhere?[/color]

        I usually use the -r command-line option on Linux; never tried the -a
        interactive PHP thing.

        Just tried it on Windows and (after solving a little quoting problem) it
        worked ...


        C:\Utils\php>ph p -r "echo date(\"Y-m-d\"), \"\n\";"
        2006-01-02

        C:\Utils\php>

        --
        Mail to my "From:" address is readable by all at http://www.dodgeit.com/
        == ** ## !! ------------------------------------------------ !! ## ** ==
        TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
        may bypass my spam filter. If it does, I may reply from another address!

        Comment

        Working...