是否有任何库或是否可以评估PHP内的JavaScript?

I have some html with inline javascript, I want to extract some values by php, shortly, I'm looking for something like:

<?php
$jsre = new JavascriptRunTime();
$jsre->run("var a = 1; var b = a + 1; var c = {hello: a, world: b};");

$a = $jsre->lookinto("a"); // $a = 1;
$b = $jsre->lookinto("b"); // $b = 2;
$c = $jsre->lookinto("c"); // $c = array("hello" => 1, "world => 2");

Or is it possible to write one?

This is probably the closest thing to what you want -- I wouldn't trust anything but this

http://php.net/manual/en/book.v8js.php