Skip to content

Commit f15261f

Browse files
committed
fix notice and empty check
1 parent c4cd26a commit f15261f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

php-amqp/emit_log_topic.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
$channel = new AMQPChannel($connection);
1313

1414

15-
$routing_key = (isset($argv[1]))? $argv[1] : 'anonymous.info';
15+
$routing_key = isset($argv[1]) && !empty($argv[1]) ? $argv[1] : 'anonymous.info';
1616

1717
$message = implode(' ',array_slice($argv, 2));
1818
if(empty($message)) $message = "Hello World!";
@@ -28,6 +28,6 @@
2828

2929
$exchange->publish($message, $routing_key);
3030
echo " [x] Sent {$routing_key}:{$message}", PHP_EOL;
31-
} catch(Exception $ex) {
31+
} catch(Exception $ex) {
3232
print_r($ex);
3333
}

php/emit_log_topic.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
$channel->exchange_declare('topic_logs', 'topic', false, false, false);
1212

13-
$routing_key = $argv[1];
14-
if(empty($routing_key)) $routing_key = "anonymous.info";
13+
$routing_key = isset($argv[1]) && !empty($argv[1]) ? $argv[1] : 'anonymous.info';
1514
$data = implode(' ', array_slice($argv, 2));
1615
if(empty($data)) $data = "Hello World!";
1716

0 commit comments

Comments
 (0)