How To Run PHP From Windows Command Line in WAMPServer

前端 未结 11 715
予麋鹿
予麋鹿 2020-11-22 04:58

I\'m new to php and wanted to run php from command line. I have installed WAMP and set the \"System Variables\" to my php folder ( which is C:\\wamp\\bin\\php\\php5.4.

11条回答
  •  再見小時候
    2020-11-22 05:24

    The problem you are describing sounds like your version of PHP might be missing the readline PHP module, causing the interactive shell to not work. I base this on this PHP bug submission.

    Try running

    php -m
    

    And see if "readline" appears in the output.

    There might be good reasons for omitting readline from the distribution. PHP is typically executed by a web server; so it is not really need for most use cases. I am sure you can execute PHP code in a file from the command prompt, using:

    php file.php
    

    There is also the phpsh project which provides a (better) interactive shell for PHP. However, some people have had trouble running it under Windows (I did not try this myself).

    Edit: According to the documentation here, readline is not supported under Windows:

    Note: This extension is not available on Windows platforms.

    So, if that is correct, your options are:

    • Avoid the interactive shell, and just execute PHP code in files from the command line - this should work well
    • Try getting phpsh to work under Windows

提交回复
热议问题