<?php
$_HOST = 'IPaddress';
$_PORT = 1883; // Use port 8883 for SSL
$_TOPIC = 'topicToPublishOn';
$_PAYLOAD = $str;
$_QOS = 0;
$client = new Mosquitto\Client("myClient");
$client->connect($_HOST, $_PORT);
$client->publish($_TOPIC, $_PAYLOAD)
$client->loop();
?>
I do not want to open a connection every time I call this file. If a connection to the server is already present, I should be able to just go ahead and publish my data.