Q:

Is it possible to include and call a JavaScript function from a PHP script? And how?

I don't know how I am going to achieve this, but...
I have a server-side, PHP CLI script. It will be run from the command-line. My PHP script needs to call a function in a JavaScript library and capture the return value. I need to find a way to run the JavaScript server-side. How can I achieve this?
Solution:
Using Rhino, you can run JavaScript as a command line script. First, download and extract Rhino. Then, assuming your scripts look like this:
PHP:
<?php
# myscript.php
$pathToRhinoJar = './rhino1_7R2/js.jar';
$javascriptFile = './test.js';
$output = shell_exec("java -jar $pathToRhinoJar $javascriptFile command line arguments");
echo "Response from javascript:\n $output";

JavaScript:
/* test.js */
for (i in arguments) {
  print(arguments[i])
}

This would be the result:
$ php ./myscript.php
Response from javascript:
command
line
arguments

A:

Unless you're talking about some form of client side PHP or server side JavaScript, then what you're referring to won't work.
PHP is executed on the server side.
JavaScript is executed on the client side.
One can't "call a method" on another because the PHP has already executed before the JavaScript can be called by the client.
The only way to make something like that work would be to provide some way for the JavaScript to execute and then post the result of the method back to the server via an AJAX call.

A:

Well technically you could do what you want.

Find a command line JS interpreter, this might be a good starting point
Make a JS script that accepts input and produces output
Start doing whatever you are doing in php
Throw a $output = system('./jsInterpreter -param value', $retval); or similar
Do something with data

EDIT: Rhino seems to be a perfect match for your needs:

Predefined Properties
Scripts executing in the shell have access to some additional properties of the top-level object.
  arguments
The arguments object is an array containing the strings of all the arguments given at the command line when the shell was invoked.

