SAMConnection::subscribe

Create a subscription to a specified topic.

&reftitle.description; `string` `SAMConnection::subscribe` `string` `targetTopic`

The "subscribe" method is used to create a new subscription to a specified topic.

&reftitle.parameters;

`targetTopic`

- The identity of the topic (topic://topicname) to subscribe to.

&reftitle.returnvalues;

A subscription identifier that can be used in a subsequent receive call as a selector to obtain any topic data or &false; if an error occurred. The subscription identifier should be used in the receive call in place of the simple topic name.

&reftitle.examples;

### Subscribe to a topic

    <?php
    $subid = $conn->subscribe('topic://A');
    if (!$subid) {
      // The subscribe failed!
      echo "Subscribe failed ($conn->errno) $conn->error";
    }
    ?>

&reftitle.seealso;

- samconnection.unsubscribe