How can I force PHP Version for Command Line?

前端 未结 7 1777
说谎
说谎 2020-12-17 17:01

I am hosted with 1and1.com, and I have setup my files to be parsed with php5 using .htaccess.

But that only works in apache, and not in command line, wh

7条回答
  •  太阳男子
    2020-12-17 17:19

    If you can execute PHP scripts directly in the shell like:

    $ script.php
    

    you can specify the binary that will execute the script in it's first line:

    #!/usr/bin/php
    

    That line is called shebang. The line might differ on your system, you need to know the full file system path of the PHP CLI binary you want to use for that script.

    If you execute that file in the shell, the specified binary will be used. Same for cron.

    If you execute that file via your webserver, PHP will drop that line silently.

    See as well: Features: Using PHP from the command line

提交回复
热议问题