How can PHP be integrated with HTML/JS to create a more user-friendly interface for controlling devices like lamps?

To create a more user-friendly interface for controlling devices like lamps, PHP can be integrated with HTML/JS to allow users to interact with the devices through a web interface. This can be achieved by using PHP to handle the backend logic, such as sending commands to the devices, and then using HTML/JS to create the user interface for users to interact with.

<?php
// PHP code to control lamps
if(isset($_POST['lamp_on'])){
    // Code to turn on the lamp
    echo "Lamp turned on";
}
if(isset($_POST['lamp_off'])){
    // Code to turn off the lamp
    echo "Lamp turned off";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Lamp Controller</title>
</head>
<body>
    <form method="post">
        <input type="submit" name="lamp_on" value="Turn On Lamp">
        <input type="submit" name="lamp_off" value="Turn Off Lamp">
    </form>
</body>
</html>