S
S
Sergey delphinpro2015-06-28 12:04:43
PHP
Sergey delphinpro, 2015-06-28 12:04:43

What is the best way to get data from a js file?

There is a js file, it contains the declaration of some variables

o.prop1 = 12;

o.prop2 = {
  key: value
}

In addition, it may contain arbitrary code. We need to get the values ​​of some properties of the "o" object.
You can parse with regular expressions, but this is not reliable, because the contents of the file may change.
There was an idea to use the javascript interpreter written in php. To drive the file code into it, get what you need at the output.
So the question is - where can I get such a sandbox interpreter, preferably with the ability to be installed by the composer?
Or maybe there is another way to get data, without regular expressions and a sandbox?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2015-06-28
@delphinpro

There is a php extension: V8js - for integrating the V8 engine into PHP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question