Ejemplo n.º 1
0
 // Create a thrift connection (Boiler plate)
 $socket = new TSocket('localhost', '9090');
 $transport = new TBufferedTransport($socket);
 $protocol = new TBinaryProtocol($transport);
 // Create a calculator client
 $client = new CalculatorClient($protocol);
 // Open up the connection
 $transport->open();
 // First, lets do something simple
 // Create a simple arithmatic operation (99 / 3)
 $operation = new ArithmeticOperation();
 $operation->op = BinaryOperation::DIVISION;
 $operation->lh_term = 99;
 $operation->rh_term = 3;
 // Perform operation on the server
 $sum = $client->calc($operation);
 print_r($sum);
 // Next, let's create the Matrix:
 //  | 1 2 3 |
 //  | 4 5 6 |
 //  | 7 8 9 |
 $m1 = new Matrix();
 $m1->rows = 3;
 $m1->cols = 3;
 $m1->data = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
 // Let's calculate its transpose, much to difficult in PHP!
 $m2 = $client->transpose($m1);
 echo "The Trasnpose of m1 is :\r\n";
 print_r($m2);
 // Next, Let's now multiply m with its transpose, again too hard for PHP
 $m3 = $client->mult($m1, $m2);