<?php
if (isset($_GET['go'], $_GET['nom'], $_GET['email'])) {
    $ctx = new JSContext();
    $js = file_get_contents(__DIR__ . '/verif-form.js');
    
    $fields = array(
        'nom' => $_GET['nom'],
        'email' => $_GET['email'],
    );
    $data = json_encode($fields);
    
    $js .= "
var data = $data;
verificationMultiPlateforme(data);
";
    $validation = $ctx->evaluateScript($js);
    var_dump($validation);
}
?>
<?php header('Content-type: text/html; charset=UTF-8'); ?>
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <title>Test PECL::Spidermonkey</title>
  <link rel="stylesheet" href="test.css" type="text/css" media="screen" />
  <script type="text/javascript" src="verif-form.js"></script>
  <script type="text/javascript" src="navigateur.js"></script>
</head>
<body>
  <div id="errors">
    <p id="error-nom" 
      <?php if (!isset($validation->nom->ok) 
        || $validation->nom->ok) : ?>style="display: none;"<?php endif ; ?>>
        Le nom est obligatoire
    </p>
    <p id="error-email" 
      <?php if (!isset($validation->email->ok) 
        || $validation->email->ok) : ?>style="display: none;"<?php endif ; ?>>
        L'E-mail est obligatoire ; ou incorrect
    </p>
  </div>
  <form method="get" action="test.php" onsubmit="return verificationJsNavigateur();">
    <p>
      <label for="nom">Nom : </label>
      <input type="text" name="nom" id="nom" />
    </p>
    <p>
      <label for="email">E-Mail : </label>
      <input type="text" name="email" id="email" />
    </p>
    <p>
      <input type="submit" name="go" value="Go !" />
    </p>
  </form>
</body>
</html>