How can PHP be used to properly display data sent from an ESP8266 on a web page without exposing sensitive information?

When displaying data sent from an ESP8266 on a web page using PHP, it is important to ensure that sensitive information is not exposed to unauthorized users. To address this, you can sanitize the data received from the ESP8266 before displaying it on the web page. This can be done by using PHP functions such as htmlspecialchars() to escape special characters and prevent any potential XSS attacks.

<?php
// Assuming $data is the variable containing the data sent from ESP8266
$sanitized_data = htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
echo $sanitized_data;
?>