No output from PHP interactive on Windows

前端 未结 8 2075
轻奢々
轻奢々 2020-12-16 13:28

I\'m running php interactively from xampp (5.4.7) on my Win 7 machine and cannot get any output from the window. I searched around various solutions and nothing so far has

8条回答
  •  庸人自扰
    2020-12-16 13:47

    If you start "php -a" and see "Interactive mode enabled" instead of "Interactive shell", then your copy of php was likely compiled without readline support, and there is no interactive shell.

    As far as I know, Windows copies of PHP are all compiled without readline support. This makes the "-a" option worthless in Windows (at least to me).

    "php -a" is supposed to work like this (output from a linux copy of php in this case):

    $ php -a
    Interactive shell
    
    php > echo 5+8;
    13
    php > exit
    $
    

    "php -a" in a Windows copy of PHP is not an interactive shell, and so effectively works the same as leaving off the "-a" option. Use F6 or CTRL+Z to type the EOF character to finish the script (appears as ^Z):

    C:\>php -a
    Interactive mode enabled
    
    
    ^Z
    13
    C:\>
    

    Leave off the "-a" and you get essentially the same results (minus the text "Interactive mode enabled":

    C:\>php
    
    ^Z
    13
    C:\>
    

    If you use "php -a" and get the text "Interactive mode enabled" and don't get the output for cli.prompt (usually "php >"), then you should check your php version (with "php -v") to make sure it is at least 5.1, and your php modules (with "php -m") to make sure the "readline" module is listed.

提交回复
热议问题