V8Js> <Tipos Resource
Last updated: Fri, 24 Feb 2012

Exemplos

Basic usage

Exemplo #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);
}

?>

O exemplo acima irĂ¡ imprimir:

Hello World!
int(13)


V8Js> <Tipos Resource
Last updated: Fri, 24 Feb 2012
 
User Contributed Notes
Exemplos
Anonymous
26-Feb-2012 10:27
Yo dawg, i herd you like script so we put some script in your script ...
foo at bar dot com
26-Feb-2012 07:48
Next stop: node.php - coding php in javascript?

Thats the perfect tool for producing crapware...
SFera
25-Feb-2012 08:12
This feature is a response to node.js project. Coding javascript on the server side. Don't mistake serverside code for clientside code.
ben at chico dot com
25-Feb-2012 01:15
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.
robertwhurst at gmail dot com
25-Feb-2012 12:27
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.

V8Js> <Tipos Resource
Last updated: Fri, 24 Feb 2012