How can I run a php without a web server?

前端 未结 5 676
孤城傲影
孤城傲影 2020-11-30 00:10

I would like to ask if I can run a php without having installed a web server. Do I have to use the php like CGI and run my page via command line? And if so, what are the ste

5条回答
  •  生来不讨喜
    2020-11-30 01:04

    PHP is a normal sripting language similar to bash or python or perl. So a script with shebang works, at least on linux.

    Example PHP file:

    #!/usr/bin/env php
    
    
    

    How to run it:

    $ chmod 755 hello.php  # do this only once
    $ ./hello.php
    

提交回复
热议问题