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
As of PHP 5.1.0 (7.1.0 on windows) PHP can be executed from the shell by running
php -a
This starts PHP's interactive shell. More info here.
With PHP's shell, running you can require files the same way you would from a file.
So if the previous command was run from the folder containing the file:
php > require 'myFile.php';
If it is in a subfolder:
php > require 'path/to/file/myFile.php';
Then execute any function defined in myFile.php.
php > myFunction(myParamsIfAny);
I guess you can use any variable defined in the same file or require any other file containing the variables needed, although I haven't tried it.