How to execute in PHP interactive mode

前端 未结 2 896
悲&欢浪女
悲&欢浪女 2021-02-12 03:45

I am new to PHP, and I just wanted to run PHP in a command prompt (interactive mode).

So I typed this code:

`php -v`
``
         


        
2条回答
  •  梦谈多话
    2021-02-12 04:30

    If following your command with Ctrl + D isn't working, you probably don't have Interactive Shell (which apparently gives input after each line). That requires compiling php with special options. But if php -a says interactive mode, you can type directly into it and send Ctrl + Z at the end of the file.

    php -a
    interactive mode enabled
    
    
    ^Z
    

    (Hit enter)

    hello there world!
    phpinfo....
    

    There's more information in the comments in the PHP comments.

提交回复
热议问题