fix notice and empty check

This commit is contained in:
seyfer 2015-11-25 15:32:37 +07:00
parent c4cd26a3f7
commit f15261f500
2 changed files with 3 additions and 4 deletions

View File

@ -12,7 +12,7 @@ $connection->connect();
$channel = new AMQPChannel($connection);
$routing_key = (isset($argv[1]))? $argv[1] : 'anonymous.info';
$routing_key = isset($argv[1]) && !empty($argv[1]) ? $argv[1] : 'anonymous.info';
$message = implode(' ',array_slice($argv, 2));
if(empty($message)) $message = "Hello World!";
@ -28,6 +28,6 @@ try {
$exchange->publish($message, $routing_key);
echo " [x] Sent {$routing_key}:{$message}", PHP_EOL;
} catch(Exception $ex) {
} catch(Exception $ex) {
print_r($ex);
}

View File

@ -10,8 +10,7 @@ $channel = $connection->channel();
$channel->exchange_declare('topic_logs', 'topic', false, false, false);
$routing_key = $argv[1];
if(empty($routing_key)) $routing_key = "anonymous.info";
$routing_key = isset($argv[1]) && !empty($argv[1]) ? $argv[1] : 'anonymous.info';
$data = implode(' ', array_slice($argv, 2));
if(empty($data)) $data = "Hello World!";