How can the code in the provided example be optimized for better performance and layout consistency?

The code can be optimized by using a consistent coding style and reducing unnecessary repetition. One way to achieve this is by using functions to encapsulate repetitive tasks and improve code readability. Additionally, using proper indentation and spacing can enhance the overall layout consistency of the code.

<?php

function calculateSquare($num) {
    return $num * $num;
}

function calculateCube($num) {
    return $num * $num * $num;
}

$number = 5;

echo "Square of $number: " . calculateSquare($number) . "\n";
echo "Cube of $number: " . calculateCube($number) . "\n";

?>