setError('ZeroDivisionError','Cannot divide by zero'); return $Error; } else { return $x / $y; } } } class Colors { function listColors() { $colors = array ( array('name'=>'maroon','r'=>'80','g'=>'00','b'=>'00'), array('name'=>'yellow','r'=>'FF','g'=>'FF','b'=>'00'), array('name'=>'salmon','r'=>'FA','g'=>'80','b'=>'72'), ); return $colors; } } $S = & new ScriptServer_Server_PostOffice(); $S->addHandler(new Math()); $S->addHandler(new Colors()); if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'], 'client')==0) { // Compress the Javascript // define('SCRIPT_SERVER_RENDER_FORMATTING',FALSE); require_once SCRIPT_SERVER . 'Renderer.php'; $R = & ScriptServer_Renderer::load(); $R->addToPHP(); $R->addVarDump(); $R->addXmlHttp(); $R->addPost(); $G = & $S->getGenerator(); $R->addScript($G->getClient()); $script = $R->toString(); header('Content-Length: '.strlen($script)); header('Content-Type: text/javascript'); echo $script; } else { // Include error handler - PHP errors, warnings and notices serialized to JS require_once SCRIPT_SERVER . 'ErrorHandler.php'; $S->serve(); } ?>