Примеры

Basic usage

Пример #1 Basic Javascript execution

<?php

$v8 
= new V8Js();

/* basic.js */
$JS = <<< EOT
len = print('Hello' + ' ' + 'World!' + "\\n");
len;
EOT;

try {
  
var_dump($v8->executeString($JS'basic.js'));
} catch (
V8JsException $e) {
  
var_dump($e);
}

?>

Результат выполнения данного примера:

Hello World!
int(13)

Коментарии

PHP is awesome and all, but please, for the love of God, please stop trying to code JavaScript in it! All this does is encourage bad programmers to write even worse JavaScript.

Quality web applications are constructed with JavaScript written properly; in a .js file, If one file is to small the use a module system like RequireJS.
2012-02-25 04:27:20
http://php5.kiev.ua/manual/ru/v8js.examples.html
While the usefulness of embedding javascript into PHP may not seem immediately obvious, a highly useful scenario presents itself to me immediately: The ability to run phpunit test on not only your PHP functions, but also the .js files used within your application!

Yes, there are JS unit tests, but the utility of having everything in one place with proper deps checking should not be ignored.
2012-02-25 05:15:19
http://php5.kiev.ua/manual/ru/v8js.examples.html
Автор:
This feature is a response to node.js project. Coding javascript on the server side. Don't mistake serverside code for clientside code.
2012-02-25 12:12:07
http://php5.kiev.ua/manual/ru/v8js.examples.html
Автор:
Next stop: node.php - coding php in javascript?

Thats the perfect tool for producing crapware...
2012-02-27 00:48:18
http://php5.kiev.ua/manual/ru/v8js.examples.html
Автор:
Yo dawg, i herd you like script so we put some script in your script ...
2012-02-27 03:27:03
http://php5.kiev.ua/manual/ru/v8js.examples.html

    Поддержать сайт на родительском проекте КГБ