Merge pull request #23062 from HannahShiSFB/greeter-client-message

PHP: better error checking in helloworld greeter_client
pull/23077/head
Stanley Cheung 5 years ago committed by GitHub
commit f316a02823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      examples/php/greeter_client.php

@ -29,10 +29,12 @@ function greet($name)
$request = new Helloworld\HelloRequest();
$request->setName($name);
list($reply, $status) = $client->SayHello($request)->wait();
$message = $reply->getMessage();
return $message;
if ($status->code !== Grpc\STATUS_OK) {
echo "ERROR: ".$status->code.", ".$status->details."\n";
exit(1);
}
echo $reply->getMessage()."\n";
}
$name = !empty($argv[1]) ? $argv[1] : 'world';
echo greet($name)."\n";
greet($name);

Loading…
Cancel
Save