"is it possible to include and call a javascript function from a php script? and how?" Code Answer

4

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.

By omer15 on July 1 2022

Answers related to “is it possible to include and call a javascript function from a php script? and how?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.