How to call a php function from the command line

By using the -r parameter we can run a script in-line.

php -r "require 'mylocation.php'; callmyfunc(143);"

where -r Run PHP without using script tags <?..?>

The above line will call callmyfunc() function with numeric argument 143 inside a mylocation.php file.
To run the above command you chould be in the directory where mylocation.php resides.