P
P
pushbot2014-09-21 22:57:00
PHP
pushbot, 2014-09-21 22:57:00

How to execute js code from php?

Given: a large obfuscated js function that performs numerical calculations.
Is it somehow possible to execute it by passing parameters and return the result in another environment? For example from php.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Vsk, 2014-09-21
@pushbot

Put phantom.js , make the necessary script with this function and call it from php, it seems, with:

<?php
$var = exec('phantomjs heavyFunction.js params');

Naturally, in order for this exec to return exactly the data you need, this must be described in the function that you feed to the phantom. It's all described in the documentation.

M
MAXH0, 2014-09-21
@MAXH0

I did not understand - execute on the client and return the result to the server?
Or do everything on the server?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question