PHP Two Column Layout: Left Right Output

In PHP, we can use the echo function to display data on a webpage. Here is a simple example showing how to output data on the left and right sides of a webpage.

<?php
$leftData = "Left data";
$rightData = "Right data";
?>

<!DOCTYPE html>
<html>
<head>
    <title>Left Right Data</title>
</head>
<body>
    <div style="float: left; width: 50%;">
        <?php echo $leftData; ?>
    </div>
    <div style="float: right; width: 50%;">
        <?php echo $rightData; ?>
    </div>
</body>
</html>

In this example, we first define two variables $leftData and $rightData to store the data to be output on the left and right sides. We then use the echo function on the page to output the values of these two variables into two div elements on the left and right, achieving left and right alignment by setting the styles of these div elements.

bannerAds