The following is the heartbeat monitoring code snippet of the web server background that keeps it running at all times through the "php XXX.php" command. How do I display $A in try on the front-end browser? Thanks!
while (true) {
if ($stomp == null || !$stomp->getClient()->isConnected()) {
echo "connection not exists, will reconnect after 10s.", PHP_EOL;
sleep(10);
$stomp = start_consume();
}
## Try { Business logic. $A = $stomp->read(); echo "start consumer:"; echo "<br/>";// echo $A; $arr = explode(':',$A); // echo "<br/>"; // $B = json_decode($A,true); $arr1 = ($arr[16]); // var_dump ($arr1[0]); echo "<br/>"; $B = json_encode($arr1,true); echo $B; // $B1 = json_decode($B,true); echo "<br/>"; } catch(HeartbeatException $e) {
echo 'The server failed to send us heartbeats within the defined interval.', PHP_EOL; $stomp->getClient()->disconnect(); } catch (Exception $e) { echo 'process message occurs error '. $e->getMessage() , PHP_EOL; }
Yours is PHP code, heartbeat monitoring. You use the front-end to always request this method. When $A is passed to the front-end, you pass it how you pass the value to the front-end.
Generally, the front end uses ajax to request php, and php uses echo json_encode to return to ajax