Call a PHP function from the command line

后端 未结 6 2090
野性不改
野性不改 2020-12-29 19:13

I have a file called address.php with a few functions in it. I want to call a specific function in that file from the command line. How?

The name of the function is

6条回答
  •  春和景丽
    2020-12-29 19:34

    Use

    php  -r 'include  "/var/www/test/address.php";exportAddress(1);'
    

    where "/var/www/test/arr.php" is the file name, including path, and exportAddress() is a function inside that file.

提交回复
热议问题