本文介绍了从命令行调用php函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为address.php的文件,里面有几个函数。我想从命令行调用该文件中的特定功能,怎么样?该函数的名称叫做exportAddress,该函数需要一个单一的参数。使用 - 解释方案
php -rrequire'address.php'; 参数可以在脚本中运行。 exportAddress(12345);
没有其他选项。 PHP中的函数只能由PHP脚本调用。
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 called exportAddress and that function expects a single parameter
解决方案
By using the -r parameter you can run a script in-line.
php -r "require 'address.php'; exportAddress(12345);"
There are no other options. A function in PHP can only be called by a PHP script.
这篇关于从命令行调用php函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!