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

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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


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... ????


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

zeltus wrote:
Quoted text here. Click to load it

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.

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

zeltus wrote:
Quoted text here. Click to load it

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>php -r "echo date(\"Y-m-d\"), \"\n\";"


Mail to my "From:" address is readable by all at
== ** ## !! ------------------------------------------------ !! ## ** ==
may bypass my spam filter. If it does, I may reply from another address!

Site Timeline