How can a loop structure be optimized to efficiently list all square numbers up to a specified limit in PHP?

To efficiently list all square numbers up to a specified limit in PHP, we can use a loop structure such as a for loop and calculate the square of each number within the loop. This way, we can avoid unnecessary calculations and optimize the code for better performance.

<?php
$limit = 10;

for ($i = 1; $i <= $limit; $i++) {
    $square = $i * $i;
    echo $square . " ";
}
?>