How can PHP be used to control relay systems via URL parameters and XML?

To control relay systems via URL parameters and XML using PHP, you can create a PHP script that receives the desired relay status as a URL parameter, then generates an XML file with the relay status information. This XML file can be read by the relay system to control the relays accordingly.

<?php
// Retrieve relay status from URL parameter
$relayStatus = $_GET['relay'];

// Create XML string with relay status information
$xml = "<?xml version='1.0' encoding='UTF-8'?><relay><status>$relayStatus</status></relay>";

// Save XML string to a file
file_put_contents('relay_status.xml', $xml);

echo "Relay status updated to $relayStatus";
?>